// and may be used for calculating defaultCenturyStart when needed.
private transient long defaultCenturyBase;
- // We need to preserve time zone type when parsing specific
- // time zone text (xxx Standard Time vs xxx Daylight Time)
- private transient TimeType tztype = TimeType.UNKNOWN;
-
private static final int millisPerHour = 60 * 60 * 1000;
// When possessing ISO format, the ERA may be ommitted is the
int pos = parsePos.getIndex();
int start = pos;
- // Reset tztype
- tztype = TimeType.UNKNOWN;
+ Output<TimeType> tzTimeType = new Output<TimeType>(TimeType.UNKNOWN);
boolean[] ambiguousYear = { false };
// item index for the first numeric field within a contiguous numeric run
// Parse a numeric field
pos = subParse(text, pos, field.type, len,
- true, false, ambiguousYear, cal, numericLeapMonthFormatter);
+ true, false, ambiguousYear, cal, numericLeapMonthFormatter, tzTimeType);
if (pos < 0) {
// If the parse fails anywhere in the numeric run, back up to the
int s = pos;
pos = subParse(text, pos, field.type, field.length,
- false, true, ambiguousYear, cal, numericLeapMonthFormatter);
+ false, true, ambiguousYear, cal, numericLeapMonthFormatter, tzTimeType);
if (pos < 0) {
if (pos == ISOSpecialEra) {
if (i+1 < items.length) {
String patl = null;
- // if it will cause a class cast exception to String, we can't use it
+ // if it will cause a class cast exception to String, we can't use it
try {
patl = (String)items[i+1];
} catch(ClassCastException cce) {
// front or the back of the default century. This only works because we adjust
// the year correctly to start with in other cases -- see subParse().
try {
+ TimeType tztype = tzTimeType.value;
if (ambiguousYear[0] || tztype != TimeType.UNKNOWN) {
// We need a copy of the fields, and we need to avoid triggering a call to
// complete(), which will recalculate the fields. Since we can't access
boolean obeyCount, boolean allowNegative,
boolean[] ambiguousYear, Calendar cal)
{
- return subParse(text, start, ch, count, obeyCount, allowNegative, ambiguousYear, cal, null);
+ return subParse(text, start, ch, count, obeyCount, allowNegative, ambiguousYear, cal, null, null);
}
/**
* @param ambiguousYear return parameter; upon return, if ambiguousYear[0]
* is true, then a two-digit year was parsed and may need to be readjusted.
* @param cal
- * @param numericLeapMonthFormatter if non-null, used to parse numeric leap months.
+ * @param numericLeapMonthFormatter if non-null, used to parse numeric leap months.
+ * @param tzTimeType the type of parsed time zone - standard, daylight or unknown (output).
+ * This parameter can be null if caller does not need the information.
* @return the new start position if matching succeeded; a negative
* number indicating matching failure, otherwise. As a side effect,
* set the appropriate field of <code>cal</code> with the parsed
@SuppressWarnings("fallthrough")
private int subParse(String text, int start, char ch, int count,
boolean obeyCount, boolean allowNegative,
- boolean[] ambiguousYear, Calendar cal, MessageFormat numericLeapMonthFormatter)
+ boolean[] ambiguousYear, Calendar cal,
+ MessageFormat numericLeapMonthFormatter, Output<TimeType> tzTimeType)
{
Number number = null;
NumberFormat currentNumberFormat = null;
return pos.getIndex();
case 17: // 'z' - ZONE_OFFSET
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
Style style = (count < 4) ? Style.SPECIFIC_SHORT : Style.SPECIFIC_LONG;
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}
}
case 23: // 'Z' - TIMEZONE_RFC
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
Style style = (count < 4) ? Style.ISO_BASIC_LOCAL_FULL : ((count == 5) ? Style.ISO_EXTENDED_FULL : Style.LOCALIZED_GMT);
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}
}
case 24: // 'v' - TIMEZONE_GENERIC
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
// Note: 'v' only supports count 1 and 4
Style style = (count < 4) ? Style.GENERIC_SHORT : Style.GENERIC_LONG;
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}
}
case 29: // 'V' - TIMEZONE_SPECIAL
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
Style style = null;
switch (count) {
case 1:
}
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}
}
case 31: // 'O' - TIMEZONE_LOCALIZED_GMT_OFFSET
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
Style style = (count < 4) ? Style.LOCALIZED_GMT_SHORT : Style.LOCALIZED_GMT;
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}
}
case 32: // 'X' - TIMEZONE_ISO
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
Style style;
switch (count) {
case 1:
}
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}
}
case 33: // 'x' - TIMEZONE_ISO_LOCAL
{
- Output<TimeType> tzTimeType = new Output<TimeType>();
Style style;
switch (count) {
case 1:
}
TimeZone tz = tzFormat().parse(style, text, pos, tzTimeType);
if (tz != null) {
- tztype = tzTimeType.value;
cal.setTimeZone(tz);
return pos.getIndex();
}