commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <flame...@gmail.com>
Subject Re: svn commit: r891542 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang3/time/FastDateFormat.java test/org/apache/commons/lang3/time/FastDateFormatTest.java
Date Fri, 18 Dec 2009 07:21:29 GMT
Switched to getTimeInMillis() :)

On Thu, Dec 17, 2009 at 10:11 AM, sebb <sebbaz@gmail.com> wrote:
> On 17/12/2009, bayard@apache.org <bayard@apache.org> wrote:
>> Author: bayard
>>  Date: Thu Dec 17 06:04:28 2009
>>  New Revision: 891542
>>
>>  URL: http://svn.apache.org/viewvc?rev=891542&view=rev
>>  Log:
>>  Fixing LANG-538 - you need to call getTime() on a calendar sometimes to get it
in the right state, otherwise the timezone gets out of whack.
>>
>>  Modified:
>>     commons/proper/lang/trunk/src/java/org/apache/commons/lang3/time/FastDateFormat.java
>>     commons/proper/lang/trunk/src/test/org/apache/commons/lang3/time/FastDateFormatTest.java
>>
>>  Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang3/time/FastDateFormat.java
>>  URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang3/time/FastDateFormat.java?rev=891542&r1=891541&r2=891542&view=diff
>>  ==============================================================================
>>  --- commons/proper/lang/trunk/src/java/org/apache/commons/lang3/time/FastDateFormat.java
(original)
>>  +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang3/time/FastDateFormat.java
Thu Dec 17 06:04:28 2009
>>  @@ -869,6 +869,7 @@
>>       */
>>      public StringBuffer format(Calendar calendar, StringBuffer buf) {
>>          if (mTimeZoneForced) {
>>  +            calendar.getTime(); /// LANG-538
>
> Seems wasteful to create a new Date; surely a better fix is:
>
>                 calendar.getTimeInMillis();
>
> Works for me on Win/XP-Java 1.5.0_22
>
>>              calendar = (Calendar) calendar.clone();
>>              calendar.setTimeZone(mTimeZone);
>>          }
>>
>>  Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang3/time/FastDateFormatTest.java
>>  URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang3/time/FastDateFormatTest.java?rev=891542&r1=891541&r2=891542&view=diff
>>  ==============================================================================
>>  --- commons/proper/lang/trunk/src/test/org/apache/commons/lang3/time/FastDateFormatTest.java
(original)
>>  +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang3/time/FastDateFormatTest.java
Thu Dec 17 06:04:28 2009
>>  @@ -333,4 +333,17 @@
>>          format = (FastDateFormat) SerializationUtils.deserialize( SerializationUtils.serialize(
format ) );
>>          assertEquals(output, format.format(cal));
>>      }
>>  +
>>  +    public void testLang538() {
>>  +        final String dateTime = "2009-10-16T16:42:16.000Z";
>>  +
>>  +        // more commonly constructed with: cal = new GregorianCalendar(2009,
9, 16, 8, 42, 16)
>>  +        // for the unit test to work in any time zone, constructing with GMT-8
rather than default locale time zone
>>  +        GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT-8"));
>>  +        cal.clear();
>>  +        cal.set(2009, 9, 16, 8, 42, 16);
>>  +
>>  +        FastDateFormat format = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
TimeZone.getTimeZone("GMT"));
>>  +        assertEquals("dateTime", dateTime, format.format(cal));
>>  +    }
>>   }
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message