Reputation: 4050
I get a string with a millisecond and a timezone like this "1353913216000+0000", so a UTC time basically. How can I convert this to my local time? I do not think i can use a DateFormat, there is no millisecond pattern.
Upvotes: 0
Views: 648
Reputation: 1059
you can use the class Calendar
Calendar c= Calendar.getInstance(TimeZone.getTimeZone("GMT+2"));
c.setTime(new Date(System.currentTimeMillis()));
System.out.println(new Date(c.getTimeInMillis()+TimeZone.getTimeZone("GMT+2").getOffset(c.getTimeInMillis())));
Upvotes: 1
Reputation: 32959
If you can't use one of the built-in parsers, you could do the following:
+
and convert to a long.Date
instance using this number+zone
to convert the date to a stringUpvotes: 0