How to Instantiate Joda DateTime from TimeZone String ID and Epoch

couchy

New Member
I am taking a look at the Joda Time library. I am trying to figure out how to construct a DateTime object given an epoch time stamp and a timezone. I am hoping that allows me to find the day of week, how of day, etc for that epoch time, in that time zone. However I am unsure how to pass the DateTimeZone to the DateTime constructor. \[code\]import org.joda.time.DateTime;import org.joda.time.DateTimeZone;import org.joda.time.Instant;public class TimeZoneTest { public static void main (String[] args) { long epoch = System.currentTimeMillis()/1000; DateTimeZone tz = new DateTimeZone( "America/New_York" ); DateTime dt = new DateTime( epoch, tz ); System.out.println( dt ); }}\[/code\]I tried the above hardcoded example of "America/New_York", but got this from the compiler. What am I doing wrong?\[code\]$ javac -cp "joda-time-2.2.jar:." TimeZoneTest.java TimeZoneTest.java:12: org.joda.time.DateTimeZone is abstract; cannot be instantiated DateTimeZone tz = new DateTimeZone( "America/New_York" ); ^ 1 error\[/code\]
 
Back
Top