Reputation: 98
I want to get "month-year" from timeStamp so using this date for-matter
but seeing strange behaviour.
SimpleDateFormat dateFormat = new SimpleDateFormat("MMM-YY");
System.out.println(dateFormat.format(1451197799000L));
The output i get from this is
from 01 to 26-12-2015 (ts : 1451111399000) = Dec-15
from 27-12-2015 (ts : 1451197799000L ) to 31-12-2015 = Dec-16
I don't know why it is happening
Upvotes: 1
Views: 92
Reputation: 1613
Check here https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html for the date and time letter patterns.
You have put "YY" for year when what you actually want is "yy".
Upvotes: 3