Reputation: 143
Date dateShipped = new SimpleDateFormat( "yyyy-MM-dd HH:MM:SS.SSS" ).parse("2013-08-29 22:41:03.537");
SimpleDateFormat fmt = new SimpleDateFormat("dd MMM yyyy",Locale.ENGLISH);
System.out.println(fmt.format(dateShipped));
this results 29 May 2016
Why is the result different?
Upvotes: 1
Views: 176
Reputation: 8466
new SimpleDateFormat( "yyyy-MM-dd HH:mm:SS.SSS" )
instead of
new SimpleDateFormat( "yyyy-MM-dd HH:MM:SS.SSS" )
MM
for Month and mm
for Minutes
Upvotes: 7
Reputation: 12252
Change MM(uppercase)
of minutes to mm (lowercase)
Date dateShipped = new SimpleDateFormat( "yyyy-MM-dd HH:mm:SS.SSS" ).parse("2013-08-29 22:41:03.537");
SimpleDateFormat fmt = new SimpleDateFormat("dd MMM yyyy",Locale.ENGLISH);
System.out.println(fmt.format(dateShipped));
Upvotes: 0
Reputation: 939
try changing your code as following
Date dateShipped = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS.SSS").parse("2013-08-29 22:41:03.537");
Upvotes: 1