LANG-1104 - FastDateParserTest.testParses fails in TimeZone America/Sao_Paulo
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1670560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56462a1e18
commit
06d724599d
|
@ -22,6 +22,7 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<release version="3.4" date="tba" description="tba">
|
<release version="3.4" date="tba" description="tba">
|
||||||
|
<action issue="LANG-1104" type="fix" dev="chas">Parse test fails for TimeZone America/Sao_Paulo</action>
|
||||||
<action issue="LANG-1103" type="add" dev="britter">Add SystemUtils.IS_JAVA_1_9</action>
|
<action issue="LANG-1103" type="add" dev="britter">Add SystemUtils.IS_JAVA_1_9</action>
|
||||||
<action issue="LANG-1102" type="update" dev="britter">Make logic for comparing OS versions in SystemUtils smarter</action>
|
<action issue="LANG-1102" type="update" dev="britter">Make logic for comparing OS versions in SystemUtils smarter</action>
|
||||||
<action issue="LANG-1091" type="update" dev="britter" due-to="Fabian Lange">Shutdown thread pools in test cases</action>
|
<action issue="LANG-1091" type="update" dev="britter" due-to="Fabian Lange">Shutdown thread pools in test cases</action>
|
||||||
|
|
|
@ -42,8 +42,8 @@ import org.junit.Test;
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public class FastDateParserTest {
|
public class FastDateParserTest {
|
||||||
private static final String SHORT_FORMAT_NOERA = "y/M/d/h/a/m/s/E/Z";
|
private static final String SHORT_FORMAT_NOERA = "y/M/d/h/a/m/s/E";
|
||||||
private static final String LONG_FORMAT_NOERA = "yyyy/MMMM/dddd/hhhh/mmmm/ss/aaaa/EEEE/ZZZZ";
|
private static final String LONG_FORMAT_NOERA = "yyyy/MMMM/dddd/hhhh/mmmm/ss/aaaa/EEEE";
|
||||||
private static final String SHORT_FORMAT = "G/" + SHORT_FORMAT_NOERA;
|
private static final String SHORT_FORMAT = "G/" + SHORT_FORMAT_NOERA;
|
||||||
private static final String LONG_FORMAT = "GGGG/" + LONG_FORMAT_NOERA;
|
private static final String LONG_FORMAT = "GGGG/" + LONG_FORMAT_NOERA;
|
||||||
|
|
||||||
|
@ -218,6 +218,7 @@ public class FastDateParserTest {
|
||||||
|
|
||||||
private void validateSdfFormatFdpParseEquality(final String format, final Locale locale, final TimeZone tz, final DateParser fdp, final Date in, final int year, final Date cs) throws ParseException {
|
private void validateSdfFormatFdpParseEquality(final String format, final Locale locale, final TimeZone tz, final DateParser fdp, final Date in, final int year, final Date cs) throws ParseException {
|
||||||
final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
|
final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
|
||||||
|
sdf.setTimeZone(tz);
|
||||||
if (format.equals(SHORT_FORMAT)) {
|
if (format.equals(SHORT_FORMAT)) {
|
||||||
sdf.set2DigitYearStart( cs );
|
sdf.set2DigitYearStart( cs );
|
||||||
}
|
}
|
||||||
|
@ -254,6 +255,29 @@ public class FastDateParserTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we cannot use historic dates to test timezone parsing, some timezones have second offsets
|
||||||
|
// as well as hours and minutes which makes the z formats a low fidelity round trip
|
||||||
|
@Test
|
||||||
|
public void testTzParses() throws Exception {
|
||||||
|
// Check that all Locales can parse the time formats we use
|
||||||
|
for(final Locale locale : Locale.getAvailableLocales()) {
|
||||||
|
final FastDateParser fdp= new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale);
|
||||||
|
|
||||||
|
for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
|
||||||
|
final Calendar cal= Calendar.getInstance(tz, locale);
|
||||||
|
cal.clear();
|
||||||
|
cal.set(Calendar.YEAR, 2000);
|
||||||
|
cal.set(Calendar.MONTH, 1);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, 10);
|
||||||
|
final Date expected= cal.getTime();
|
||||||
|
|
||||||
|
final Date actual = fdp.parse("2000/02/10 "+tz.getDisplayName(locale));
|
||||||
|
Assert.assertEquals("tz:"+tz.getID()+" locale:"+locale.getDisplayName(), expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLocales_Long_AD() throws Exception {
|
public void testLocales_Long_AD() throws Exception {
|
||||||
testLocales(LONG_FORMAT, false);
|
testLocales(LONG_FORMAT, false);
|
||||||
|
|
Loading…
Reference in New Issue