|
|
@@ -44,7 +44,7 @@ public class CellDateFormatter extends CellFormatter { |
|
|
|
|
|
|
|
private static /* final */ CellDateFormatter SIMPLE_DATE; |
|
|
|
|
|
|
|
private class DatePartHandler implements CellFormatPart.PartHandler { |
|
|
|
class DatePartHandler implements CellFormatPart.PartHandler { |
|
|
|
private int mStart = -1; |
|
|
|
private int mLen; |
|
|
|
private int hStart = -1; |
|
|
@@ -94,7 +94,10 @@ public class CellDateFormatter extends CellFormatter { |
|
|
|
case 'y': |
|
|
|
case 'Y': |
|
|
|
mStart = -1; |
|
|
|
if (part.length() == 3) |
|
|
|
// See https://issues.apache.org/bugzilla/show_bug.cgi?id=53369 |
|
|
|
if (part.length() == 1) |
|
|
|
part = "yy"; |
|
|
|
else if (part.length() == 3) |
|
|
|
part = "yyyy"; |
|
|
|
return part.toLowerCase(Locale.ROOT); |
|
|
|
|
|
|
@@ -125,6 +128,15 @@ public class CellDateFormatter extends CellFormatter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void updatePositions(int pos, int offset) { |
|
|
|
if (pos < hStart) { |
|
|
|
hStart += offset; |
|
|
|
} |
|
|
|
if (pos < mStart) { |
|
|
|
mStart += offset; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void finish(StringBuffer toAppendTo) { |
|
|
|
if (hStart >= 0 && !showAmPm) { |
|
|
|
for (int i = 0; i < hLen; i++) { |
|
|
@@ -155,10 +167,7 @@ public class CellDateFormatter extends CellFormatter { |
|
|
|
StringBuffer descBuf = CellFormatPart.parseFormat(format, |
|
|
|
CellFormatType.DATE, partHandler); |
|
|
|
partHandler.finish(descBuf); |
|
|
|
// tweak the format pattern to pass tests on JDK 1.7, |
|
|
|
// See https://issues.apache.org/bugzilla/show_bug.cgi?id=53369 |
|
|
|
String ptrn = descBuf.toString().replaceAll("((y)(?!y))(?<!yy)", "yy"); |
|
|
|
dateFmt = new SimpleDateFormat(ptrn, locale); |
|
|
|
dateFmt = new SimpleDateFormat(descBuf.toString(), locale); |
|
|
|
dateFmt.setTimeZone(LocaleUtil.getUserTimeZone()); |
|
|
|
} |
|
|
|
|