Name: gm110360 Date: 09/10/2003
FULL PRODUCT VERSION :
FULL OS VERSION :
Several versions of Windows (XP, 2000)
A DESCRIPTION OF THE PROBLEM :
Simple Date Format will parse incorrect times.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code shown below
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Errors when trying to parse invalid times.
ACTUAL -
See output
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author Peter L Bird
*
* "OutOfTimeRange.java" created on Jun 18, 2003 at 4:14:57 PM
*/
public final class OutOfTimeRange
{
public static void tryThisOne( String time )
{
try
{
System.out.println( " The Value of \""
+ time
+ "\" is\t"
+ new Date( new SimpleDateFormat( "H:mm" ).parse( time ).getTime() ).toString()
);
}
catch (Exception e)
{
System.err.println(" Er, no good " + e.getMessage());
}
}
public static void main(String[] args)
{
tryThisOne( " 4:57" );
tryThisOne( "23:57" );
tryThisOne( "30:57" );
tryThisOne( "99:57" );
tryThisOne( "99:99" );
tryThisOne( "999:99" );
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Check if the returned value is less than the number of milliseconds in a day.
(Incident Review ID: 188578)
======================================================================