public static boolean isISO8601(char[] charArray) { return isISO8601(charArray, 0, charArray.length); }
public static Date fromISO8601DateLoose( char[] buffer, int startIndex, int endIndex ) { if ( Dates.isISO8601QuickCheck( buffer, startIndex, endIndex ) ) { if ( Dates.isJsonDate( buffer, startIndex, endIndex ) ) { return Dates.fromJsonDate( buffer, startIndex, endIndex ); } else if ( Dates.isISO8601( buffer, startIndex, endIndex ) ) { return Dates.fromISO8601( buffer, startIndex, endIndex ); } else { try { return looseParse( buffer, startIndex, endIndex ); } catch ( Exception ex ) { throw new IllegalStateException( "unable to do a loose parse", ex ); } } } else { try { return looseParse( buffer, startIndex, endIndex ); } catch ( Exception ex ) { throw new IllegalStateException( "unable to do a loose parse", ex ); } } }
@Override public Date dateValue () { if ( type == TypeType.STRING ) { if ( Dates.isISO8601QuickCheck ( buffer, startIndex, endIndex ) ) { if ( Dates.isJsonDate ( buffer, startIndex, endIndex ) ) { return Dates.fromJsonDate ( buffer, startIndex, endIndex ); } else if ( Dates.isISO8601Jackson(buffer, startIndex, endIndex) ) { return Dates.fromISO8601Jackson(buffer, startIndex, endIndex); } else if ( Dates.isISO8601 ( buffer, startIndex, endIndex ) ) { return Dates.fromISO8601 ( buffer, startIndex, endIndex ); } else { throw new IllegalStateException( "Unable to convert " + stringValue () + " to date " ); } } else { throw new IllegalStateException ( "Unable to convert " + stringValue () + " to date " ); } } else { return new Date ( Dates.utc ( longValue () ) ); } }
@Override public Date dateValue () { if ( type == TypeType.STRING ) { if ( Dates.isISO8601QuickCheck ( buffer, startIndex, endIndex ) ) { if ( Dates.isJsonDate ( buffer, startIndex, endIndex ) ) { return Dates.fromJsonDate ( buffer, startIndex, endIndex ); } else if ( Dates.isISO8601Jackson(buffer, startIndex, endIndex) ) { return Dates.fromISO8601Jackson(buffer, startIndex, endIndex); } else if ( Dates.isISO8601 ( buffer, startIndex, endIndex ) ) { return Dates.fromISO8601 ( buffer, startIndex, endIndex ); } else { throw new IllegalStateException( "Unable to convert " + stringValue () + " to date " ); } } else { throw new IllegalStateException ( "Unable to convert " + stringValue () + " to date " ); } } else { return new Date ( Dates.utc ( longValue () ) ); } }
public static Date fromISO8601DateLoose(char[] buffer, int startIndex, int endIndex) { if (Dates.isISO8601QuickCheck(buffer, startIndex, endIndex)) { if (Dates.isJsonDate(buffer, startIndex, endIndex)) { return Dates.fromJsonDate(buffer, startIndex, endIndex); } else if (Dates.isISO8601(buffer, startIndex, endIndex)) { return Dates.fromISO8601(buffer, startIndex, endIndex); } else { try { return looseParse(buffer, startIndex, endIndex); } catch (Exception ex) { throw new IllegalStateException("unable to do a loose parse", ex); } } } else { try { return looseParse(buffer, startIndex, endIndex); } catch (Exception ex) { throw new IllegalStateException("unable to do a loose parse", ex); } } }
public static boolean isISO8601( char[] charArray ) { return isISO8601( charArray, 0, charArray.length ); }
if (Dates.isJsonDate ( buffer,startIndex, endIndex )) { date = Dates.fromJsonDate ( buffer, startIndex, endIndex ); } else if (Dates.isISO8601( buffer, startIndex, endIndex )) { date = Dates.fromISO8601( buffer, startIndex, endIndex ); } else {
public static boolean isISO8601( String string ) { return isISO8601( FastStringUtils.toCharArray( string ) ); }
if (Dates.isJsonDate ( buffer,startIndex, endIndex )) { date = Dates.fromJsonDate ( buffer, startIndex, endIndex ); } else if (Dates.isISO8601( buffer, startIndex, endIndex )) { date = Dates.fromISO8601( buffer, startIndex, endIndex ); } else {
public static boolean isISO8601(String string) { return isISO8601(FastStringUtils.toCharArray(string)); }
public static Date fromISO8601( char[] charArray, int from, int to ) { try { int length = to - from; if ( isISO8601( charArray, from, to ) ) { int year = CharScanner.parseInt(charArray, from + 0, from + 4); int month = CharScanner.parseInt(charArray, from + 5, from + 7); int day = CharScanner.parseInt(charArray, from + 8, from + 10); int hour = CharScanner.parseInt(charArray, from + 11, from + 13); int minute = CharScanner.parseInt(charArray, from + 14, from + 16); int second = CharScanner.parseInt(charArray, from + 17, from + 19); TimeZone tz = null; if ( charArray[ from + 19 ] == 'Z' ) { tz = GMT; } else { StringBuilder builder = new StringBuilder( 9 ); builder.append( "GMT" ); builder.append( charArray, from + 19, 6 ); String tzStr = builder.toString(); tz = TimeZone.getTimeZone( tzStr ); } return toDate( tz, year, month, day, hour, minute, second ); } else { return null; } } catch (Exception ex) { return null; } }
public static Date fromISO8601(char[] charArray, int from, int to) { try { int length = to - from; if (isISO8601(charArray, from, to)) { int year = CharScanner.parseInt(charArray, from + 0, from + 4); int month = CharScanner.parseInt(charArray, from + 5, from + 7); int day = CharScanner.parseInt(charArray, from + 8, from + 10); int hour = CharScanner.parseInt(charArray, from + 11, from + 13); int minute = CharScanner.parseInt(charArray, from + 14, from + 16); int second = CharScanner.parseInt(charArray, from + 17, from + 19); TimeZone tz = null; if (charArray[from + 19] == 'Z') { tz = GMT; } else { StringBuilder builder = new StringBuilder(9); builder.append("GMT"); builder.append(charArray, from + 19, 6); String tzStr = builder.toString(); tz = TimeZone.getTimeZone(tzStr); } return toDate(tz, year, month, day, hour, minute, second); } else { return null; } } catch (Exception ex) { return null; } }