The following program, tested against Joda 1.5.1 (2007-12-04 13:07)
shows that Joda is not able to parse date/times for a period of 5
hours on a particular day in the America/Guatemala timezone.
Everything works fine in UTC.  Because the program does not supply
daylight savings time specifiers, it would be OK for Joda to block out
1 hour but 5 hours is indicative of a bug.

Hopefully someone will be able to find the source of this bug and add
this testcase to your unit tests.  I appreciate your help.

import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
import org.joda.time.ReadableInstant;
import org.joda.time.MutableDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.Locale;

/**
 * A simple program to demonstrate a parsing problem with the Joda parsing
 * routines for a particular timezone.  Although the date format does not
 * include the daylight savings time information, at most that makes a single
 * hour ambiguous.  This program shows that several hours are not parse-able.
 */
public class DateTimeParseBug {

  public static void main(String argv[]) {
    DateTimeFormatter fmt = DateTimeFormat.shortDateTime();
    Locale locale = Locale.US;
    DateTimeZone timeZone = DateTimeZone.forID("America/Guatemala");

    // This works
    fmt.withZone(timeZone).parseDateTime("10/1/06 5:00 AM");

    // But none of these work even though the time zone changes the day before
    // happens at midnight (which causes 11pm on 9/30 to be repeated)
    fmt.withZone(timeZone).parseDateTime("10/1/06 4:00 AM");
    fmt.withZone(timeZone).parseDateTime("10/1/06 3:00 AM");
    fmt.withZone(timeZone).parseDateTime("10/1/06 2:00 AM");
    fmt.withZone(timeZone).parseDateTime("10/1/06 1:00 AM");
  }

}
import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
import org.joda.time.ReadableInstant;
import org.joda.time.MutableDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.Locale;

/**
 * A simple program to demonstrate a parsing problem with the Joda parsing
 * routines for a particular timezone.  Although the date format does not
 * include the daylight savings time information, at most that makes a single
 * hour ambiguous.  This program shows that several hours are not parse-able.
 */
public class DateTimeParseBug {

  public static void main(String argv[]) {
    DateTimeFormatter fmt = DateTimeFormat.shortDateTime();
    Locale locale = Locale.US;
    DateTimeZone timeZone = DateTimeZone.forID("America/Guatemala");

    // This works
    fmt.withZone(timeZone).parseDateTime("10/1/06 5:00 AM");

    // But none of these work even though the time zone changes the day before
    // happens at midnight (which causes 11pm on 9/30 to be repeated)
    fmt.withZone(timeZone).parseDateTime("10/1/06 4:00 AM");
    fmt.withZone(timeZone).parseDateTime("10/1/06 3:00 AM");
    fmt.withZone(timeZone).parseDateTime("10/1/06 2:00 AM");
    fmt.withZone(timeZone).parseDateTime("10/1/06 1:00 AM");
  }

}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to