I have time coming from gpslocation service in 1352437114052 format. Can some one tell me how to convert this into local time either in Java or Matlab or Excel.
Create a new Date
from your milliseconds since epoch. Then use a DateFormat
to format it in your desired timezone.
Date date = new Date(1352437114052L);
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
format.setTimeZone(TimeZone.getTimeZone("PST"));
System.out.println(format.format(date));
This is an epoch time and it represents Fri, 09 Nov 2012 04:58:34 GMT. This numeric value is an absolute point in time, irrespective to time zone.
If you want to see that point in time in different time zone, use GregorianCalendar
:
Calendar c = new GregorianCalendar(TimeZone.getTimeZone("EST"));
c.setTimeInMillis(1352437114052L);
c.get(Calendar.HOUR_OF_DAY); //20:58 the day before
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With