I am reading the Joda Time library. I am trying to figure out how to build a DateTime object given an era timestamp and timezone. I hope this allows me to find the day of the week, like day, etc. For that time, in this time zone. However, I'm not sure how to pass the DateTimeZone to the DateTime constructor.
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 ); } }
I tried the hardcoded America / New_York code above, but got it from the compiler. What am I doing wrong?
$ 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
source share