You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import org.joda.time.*;
public class PeriodMain {
public static void main(String[] argv) {
System.out.println(java.util.TimeZone.getDefault().getDisplayName());
System.out.println(org.joda.time.DateTimeZone.getDefault());
long period = 10000000000000000L;
new Period(period, PeriodType.yearDayTime()).normalizedStandard(PeriodType.dayTime());
}
}
Problem description
The program above behaves differently depending on the time zone. It works for UTC, while it fails with (what seems) any other time zone.
Test case
Success
# TZ=Etc/UTC java -cp ./joda-time-2.9.3.jar:. PeriodMain
Picked up _JAVA_OPTIONS: -Djava.awt.headless=true
Coordinated Universal Time
Etc/UTC
Failure
# TZ=Europe/Warsaw java -cp ./joda-time-2.9.3.jar:. PeriodMain
Picked up _JAVA_OPTIONS: -Djava.awt.headless=true
Central European Time
Europe/Warsaw
Exception in thread "main" java.lang.ArithmeticException: Value cannot fit in an int: 2777777777
at org.joda.time.field.FieldUtils.safeToInt(FieldUtils.java:206)
at org.joda.time.field.BaseDurationField.getDifference(BaseDurationField.java:141)
at org.joda.time.chrono.ZonedChronology$ZonedDurationField.getDifference(ZonedChronology.java:343)
at org.joda.time.chrono.BaseChronology.get(BaseChronology.java:285)
at org.joda.time.base.BasePeriod.<init>(BasePeriod.java:258)
at org.joda.time.Period.<init>(Period.java:402)
at PeriodMain.main(PeriodMain.java:11)
Other time zones fail similarly: America/Chicago, etc.
The text was updated successfully, but these errors were encountered:
Key information
Program
Problem description
The program above behaves differently depending on the time zone. It works for UTC, while it fails with (what seems) any other time zone.
Test case
Other time zones fail similarly: America/Chicago, etc.
The text was updated successfully, but these errors were encountered: