everything previous is correct, but u should also use 'mm' instead of 'MM' and vice versa because "M" Shows a minute with a zero zero value
therefore ur code will be as follows:
public void testParseJavaDate() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd_HH-MM-ss", Locale.GERMAN);
String inputtime = "2011-04-21_16-01-08";
Date parse = sdf.parse(inputtime);
sdf = new SimpleDateFormat("dd/mm/yyyy HH:MM:ss", Locale.GERMAN);
System.out.println(sdf.format(parse));
assertEquals(inputtime, sdf.format(parse));
}
and he will print
run:
21/04/2011 16:01:08
BUILD SUCCESSFUL (total time: 0 seconds)
source
share