3

Any one know how to convert UTC time to CST time using joda date time api ? My code is something like this.

DateTimeZone zone = DateTimeZone.forID("CST");
DateTime mstTime = utcDateTime.toDateTime(zone);

Api says 'The datetime zone id CST is not recognised'

paddhureddy
  • 113
  • 1
  • 8

3 Answers3

7

Short time-zone ids like "CST" are unclear and ambiguous, so they are not supported. Use a longer form, like "America/New_York".

JodaStephen
  • 60,927
  • 15
  • 95
  • 117
2

Some of the three-letter time zones (EST and MST, for example) are included in the default time zone database used by Joda. Others (CST and PST, for example) are not. (See http://joda-time.sourceforge.net/timezones.html for more details.)

The time zone IDs supported by Joda can be obtained by calling org.joda.time.DateTimeZone.getAvailableIDs(), and that set does differ from those returned by java.util.TimeZone.getAvailableIDs().

Woody
  • 145
  • 1
  • 4
1

You can use "CST6CDT" format of joda time.

udyan
  • 141
  • 5