{ WEEK_OF_MONTH, DOW_LOCAL },
{ DAY_OF_WEEK_IN_MONTH, DOW_LOCAL },
{ DAY_OF_YEAR },
+ { RESOLVE_REMAP | DAY_OF_MONTH, YEAR }, // if YEAR is set over YEAR_WOY use DAY_OF_MONTH
+ { RESOLVE_REMAP | WEEK_OF_YEAR, YEAR_WOY }, // if YEAR_WOY is set, calc based on WEEK_OF_YEAR
},
{
{ WEEK_OF_YEAR },
*/
protected int resolveFields(int[][][] precedenceTable) {
int bestField = -1;
+ int tempBestField;
for (int g=0; g<precedenceTable.length && bestField < 0; ++g) {
int[][] group = precedenceTable[g];
int bestStamp = UNSET;
}
// Record new maximum stamp & field no.
if (lineStamp > bestStamp) {
- bestStamp = lineStamp;
- bestField = line[0]; // First field refers to entire line
+ tempBestField = line[0]; // First field refers to entire line
+ if (tempBestField >= RESOLVE_REMAP) {
+ tempBestField &= (RESOLVE_REMAP-1);
+ // This check is needed to resolve some issues with UCAL_YEAR precedence mapping
+ if (tempBestField != DATE || (stamp[WEEK_OF_MONTH] < stamp[tempBestField])) {
+ bestField = tempBestField;
+ }
+ } else {
+ bestField = tempBestField;
+ }
+
+ if (bestField == tempBestField) {
+ bestStamp = lineStamp;
+ }
}
}
}
/*
*******************************************************************************
- * Copyright (C) 2001-2011, International Business Machines Corporation and *
+ * Copyright (C) 2001-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
}
}
}
+
+ public void TestParsing() {
+ String pattern = "EEE-WW-MMMM-yyyy";
+ String text = "mon-02-march-2011";
+ int expectedDay = 7;
+
+ SimpleDateFormat format = new SimpleDateFormat(pattern);
+ Calendar cal = GregorianCalendar.getInstance(Locale.US);
+ ParsePosition pos = new ParsePosition(0);
+
+ try {
+ format.parse(text, cal, pos);
+ } catch (Exception e) {
+ errln("Fail parsing: " + e);
+ }
+
+ if (cal.get(Calendar.DAY_OF_MONTH) != expectedDay) {
+ errln("Parsing failed: day of month should be '7' with pattern: \"" + pattern + "\" for text: \"" + text + "\"");
+ }
+ }
}