问题
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'
回答1:
I solved the error by adding:
public void onCreate() {
super.onCreate();
JodaTimeAndroid.init(this);
}
来源:https://stackoverflow.com/questions/29029502/error-with-joda-time-in-android-the-datetime-zone-id-america-new-york-is-not