Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4028061

DateFormat.parse fails for date in dd-MMM-yyyy format.

XMLWordPrintable

    • 1.1.4
    • generic
    • generic
    • Not verified

        DateFormat.parse() throws StringIndexOutOfBoundsException on a date formatted in
        dd-MMM-yyyy format (Currently used for English (United Kingdom) long date format.

        Steps to reproduce:
        compile and run attached code

        import java.util.Locale;
        import java.util.TimeZone;
        import java.text.DateFormat;
        import java.util.Date;

        public class k {
            
            public static void main( String argv[] ) {
                Date date;
                Date tempDate;
                DateFormat formatter;

                // 25-Mar-97 00:00:00 GMT
                date = new Date( 859248000000L );
                System.out.println( date );
                formatter = DateFormat.getDateFormat( DateFormat.LONG, Locale.UK );
                formatter.setTimeZone( TimeZone.getTimeZone( "GMT" ) );

                String temp = formatter.format( date );
                System.out.println( "Date: " + temp );

                /* Parse date string */
                try {
                    tempDate = formatter.parse( temp );
                    System.out.println( tempDate );
                }
                catch( Throwable t ) {
                    System.out.println( "Date Formatter throws: " +
                                        t.toString() );
                }


            }
        }

              nlindenbsunw Norbert Lindenberg (Inactive)
              kasmithsunw Kevin Smith (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: