How to convert UTC time in millis to formatted date-time in different time zones using joda time?

You can do the following to create a DateTime from milliseconds and give it a specific timezone.

Up vote 1 down vote favorite share g+ share fb share tw.

Example: If I have the currrentTimeInGMT = 1322137038601. How can I convert this time to the format 'yyyy/MM/dd hh:mm:ss' with date-time differing according to the time zone? Java jodatime link|improve this question edited Nov 24 '11 at 12:39oers4,5394820 asked Nov 24 '11 at 12:26Emil3,489729 75% accept rate.

– jarnbjo Nov 24 '11 at 12:45 If you're doing anything but the most trivial date/time stuff, you should use Joda Time - it's a breath of fresh air after standard JDK APIs, which rank as some of the worst in the JDK. – SteveD Nov 24 '11 at 14:26 Joda is perhaps a breath of fresh air, but also lacks some rather trivial functionality and has IMHO (at least partially) a rather unintuitive API. Nevertheless, that was not my question.

I asked Emil why he wants to use Joda for exactly this task: formatting a timestamp with a conditional time zone. – jarnbjo Nov 24 '11 at 14:44 @jarnbjo: I'm currently using the standard api for this. I just wanted to benchmark and see if Joda time give's a better performance.

For the current implementation you can refer this link . If you can give a better implementation I would like to see it. – Emil Nov 25 '11 at 6:57 The implementation you are linking to is not very clever.

It is already mentioned in the responses that you shouldn't manipulate Date or Timestamp instances to apply timezone information, since these classes have no knowledge of time zone. – jarnbjo Nov 25 '11 at 15:00.

You can do the following to create a DateTime from milliseconds and give it a specific timezone: DateTime d = new DateTime(1322137038601L). ToDateTime(DateTimeZone. ForID("Europe/Berlin")); To do the custom formatting: System.out.

Println(DateTimeFormat. ForPattern("yyyy/MM/dd hh:mm:ss"). Print(d)).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions