Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1427E17405 for ; Wed, 1 Apr 2015 04:07:51 +0000 (UTC) Received: (qmail 91339 invoked by uid 500); 1 Apr 2015 04:07:44 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 91259 invoked by uid 500); 1 Apr 2015 04:07:44 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 91250 invoked by uid 99); 1 Apr 2015 04:07:44 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 04:07:44 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id EEFADAC013F for ; Wed, 1 Apr 2015 04:07:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1670560 - in /commons/proper/lang/trunk/src: changes/changes.xml test/java/org/apache/commons/lang3/time/FastDateParserTest.java Date: Wed, 01 Apr 2015 04:07:43 -0000 To: commits@commons.apache.org From: chas@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150401040743.EEFADAC013F@hades.apache.org> Author: chas Date: Wed Apr 1 04:07:43 2015 New Revision: 1670560 URL: http://svn.apache.org/r1670560 Log: LANG-1104 - FastDateParserTest.testParses fails in TimeZone America/Sao_Paulo Modified: commons/proper/lang/trunk/src/changes/changes.xml commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java Modified: commons/proper/lang/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1670560&r1=1670559&r2=1670560&view=diff ============================================================================== --- commons/proper/lang/trunk/src/changes/changes.xml [utf-8] (original) +++ commons/proper/lang/trunk/src/changes/changes.xml [utf-8] Wed Apr 1 04:07:43 2015 @@ -22,6 +22,7 @@ + Parse test fails for TimeZone America/Sao_Paulo Add SystemUtils.IS_JAVA_1_9 Make logic for comparing OS versions in SystemUtils smarter Shutdown thread pools in test cases Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java?rev=1670560&r1=1670559&r2=1670560&view=diff ============================================================================== --- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java (original) +++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java Wed Apr 1 04:07:43 2015 @@ -42,8 +42,8 @@ import org.junit.Test; * @since 3.2 */ public class FastDateParserTest { - private static final String SHORT_FORMAT_NOERA = "y/M/d/h/a/m/s/E/Z"; - private static final String LONG_FORMAT_NOERA = "yyyy/MMMM/dddd/hhhh/mmmm/ss/aaaa/EEEE/ZZZZ"; + 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"; private static final String SHORT_FORMAT = "G/" + SHORT_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 { final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); + sdf.setTimeZone(tz); if (format.equals(SHORT_FORMAT)) { 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 public void testLocales_Long_AD() throws Exception { testLocales(LONG_FORMAT, false);