Reputation: 135
I get the date string --"2012-04-19 20:51:06". Then I get the milli time by SimpleDateFormat.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date d=sdf.parse("2012-04-19 20:51:06");
long milliTime=d.getTime()
Then the milliTime is 1334839866000L
However when I convert milliTime to date format String. The result is "2012-04-19 08:51:06"
long time = 1334839866000L;
Date date = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String t = sdf.format(date);
What's the problem?
Upvotes: 3
Views: 1620