ICU-20475 Japanese calendar era calculation should use local time, not UTC (ICU4J)

This commit is contained in:
yumaoka 2019-04-03 14:58:45 -04:00 committed by Yoshito Umaoka
parent 2f2aec5f91
commit 3d19a928e7

View file

@ -5,6 +5,7 @@ package com.ibm.icu.impl;
import java.util.Arrays;
import com.ibm.icu.util.ICUException;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.UResourceBundleIterator;
@ -201,7 +202,8 @@ public class EraRules {
/**
* Gets the current era index. This is calculated only once for an instance of
* EraRules.
* EraRules. The current era calculation is based on the default time zone at
* the time of instantiation.
*
* @return era index of current era (or 0, when current date is before the first era)
*/
@ -210,7 +212,11 @@ public class EraRules {
}
private void initCurrentEra() {
int[] fields = Grego.timeToFields(System.currentTimeMillis(), null);
long localMillis = System.currentTimeMillis();
TimeZone zone = TimeZone.getDefault();
localMillis += zone.getOffset(localMillis);
int[] fields = Grego.timeToFields(localMillis, null);
int currentEncodedDate = encodeDate(fields[0], fields[1] + 1 /* changes to 1-base */, fields[2]);
int eraIdx = numEras - 1;
while (eraIdx > 0) {