Exception:
Caused by: java.lang.IllegalArgumentException: The datetime zone id 'America/New_York' is not recognised
Android code:
DateTime dt = new DateTime();
DateTimeZone dtZone = DateTimeZone.forID("America/New_York");
DateTime dtus = dt.withZone(dtZone);
Date dateInUS = dtus.toDate();
System.out.println(dateInUS);
Why am I getting this error?
I have loaded the Joda API in Gradle:
compile 'net.danlew:android.joda:2.7.1'
I solved the error by adding:
public void onCreate() {
super.onCreate();
JodaTimeAndroid.init(this);
}
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