int minute = 0;
int second = 0;
//first string off the prefix if it exists
try
{
SimpleTimeZone zone = null;
if( date.startsWith( "D:" ) )
{
date = date.substring( 2, date.length() );
}
if( date.length() < 4 )
{
throw new IOException( "Error: Invalid date format '" + date + "'" );
}
year = Integer.parseInt( date.substring( 0, 4 ) );
if( date.length() >= 6 )
{
month = Integer.parseInt( date.substring( 4, 6 ) );
}
if( date.length() >= 8 )
{
day = Integer.parseInt( date.substring( 6, 8 ) );
}
if( date.length() >= 10 )
{
hour = Integer.parseInt( date.substring( 8, 10 ) );
}
if( date.length() >= 12 )
{
minute = Integer.parseInt( date.substring( 10, 12 ) );
}
if( date.length() >= 14 )
{
second = Integer.parseInt( date.substring( 12, 14 ) );
}
retval = new GregorianCalendar( year, month-1, day, hour, minute, second );
if( date.length() >= 15 )
{
char sign = date.charAt( 14 );
if( sign == 'Z' )
{
zone = new SimpleTimeZone(0,"Unknown");
}
else
{
int hours = 0;
int minutes = 0;
if( date.length() >= 17 )
{
if( sign == '+' )
{
//parseInt cannot handle the + sign
hours = Integer.parseInt( date.substring( 15, 17 ) );
}
else
{
hours = Integer.parseInt( date.substring( 14, 17 ) );
}
}
if( date.length() > 20 )
{
minutes = Integer.parseInt( date.substring( 18, 20 ) );
}
zone = new SimpleTimeZone( hours*60*60*1000 + minutes*60*1000, "Unknown" );
}
retval.setTimeZone( zone );
}
}
catch( NumberFormatException e )