*/
public GeneralizedTime( String generalizedTime ) throws ParseException
{
if ( generalizedTime == null )
{
throw new ParseException( I18n.err( I18n.ERR_04359 ), 0 );
}
this.upGeneralizedTime = generalizedTime;
calendar = Calendar.getInstance();
calendar.setTimeInMillis( 0 );
calendar.setLenient( false );
parseYear();
parseMonth();
parseDay();
parseHour();
if ( upGeneralizedTime.length() < 11 )
{
throw new ParseException( I18n.err( I18n.ERR_04360 ), 10 );
}
// pos 10:
// if digit => minute field
// if . or , => fraction of hour field
// if Z or + or - => timezone field
// else error
int pos = 10;
char c = upGeneralizedTime.charAt( pos );
if ( '0' <= c && c <= '9' )
{
parseMinute();
if ( upGeneralizedTime.length() < 13 )
{
throw new ParseException( I18n.err( I18n.ERR_04361 ), 12 );
}
// pos 12:
// if digit => second field
// if . or , => fraction of minute field
// if Z or + or - => timezone field
// else error
pos = 12;
c = upGeneralizedTime.charAt( pos );
if ( '0' <= c && c <= '9' )
{
parseSecond();
if ( upGeneralizedTime.length() < 15 )
{
throw new ParseException( I18n.err( I18n.ERR_04362 ), 14 );
}
// pos 14:
// if . or , => fraction of second field
// if Z or + or - => timezone field
// else error
pos = 14;
c = upGeneralizedTime.charAt( pos );
if ( c == '.' || c == ',' )
{
// read fraction of second
parseFractionOfSecond();
pos += 1 + upFractionLength;
parseTimezone( pos );
upFormat = Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION;
}
else if ( c == 'Z' || c == '+' || c == '-' )
{
// read timezone
parseTimezone( pos );
upFormat = Format.YEAR_MONTH_DAY_HOUR_MIN_SEC;
}
else
{
throw new ParseException( I18n.err( I18n.ERR_04363 ), 14 );
}
}
else if ( c == '.' || c == ',' )
{
// read fraction of minute
parseFractionOfMinute();
pos += 1 + upFractionLength;
parseTimezone( pos );
upFormat = Format.YEAR_MONTH_DAY_HOUR_MIN_FRACTION;
}
else if ( c == 'Z' || c == '+' || c == '-' )
{
// read timezone
parseTimezone( pos );
upFormat = Format.YEAR_MONTH_DAY_HOUR_MIN;
}
else
{
throw new ParseException( I18n.err( I18n.ERR_04364 ), 12 );
}
}
else if ( c == '.' || c == ',' )
{
// read fraction of hour
parseFractionOfHour();
pos += 1 + upFractionLength;
parseTimezone( pos );
upFormat = Format.YEAR_MONTH_DAY_HOUR_FRACTION;
}
else if ( c == 'Z' || c == '+' || c == '-' )
{
// read timezone
parseTimezone( pos );
upFormat = Format.YEAR_MONTH_DAY_HOUR;
}
else
{
throw new ParseException( I18n.err( I18n.ERR_04365 ), 10 );
}
// this calculates and verifies the calendar
try
{
calendar.getTimeInMillis();
}
catch ( IllegalArgumentException iae )
{
throw new ParseException( I18n.err( I18n.ERR_04366 ), 0 );
}
calendar.setLenient( true );
}