public static Date toDate(Object object) { if (object instanceof Date) { return (Date) object; } else if (object instanceof Value) { return ((Value) object).dateValue(); } else if (object instanceof Calendar) { return ((Calendar) object).getTime(); } else if (object instanceof Long) { return new Date((long) object); } else if (object instanceof String) { String val = (String) object; char[] chars = FastStringUtils.toCharArray(val); if (Dates.isISO8601QuickCheck(chars)) { return Dates.fromISO8601DateLoose(chars); } else { return toDateUS(val); } } return null; }
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 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); } } }
String val = object.toString(); char[] chars = FastStringUtils.toCharArray(val); if (Dates.isISO8601QuickCheck(chars)) { return Dates.fromISO8601DateLoose(chars); } else if (Dates.isShortDate(chars)) { if (Dates.isISO8601QuickCheck(chars)) { return Dates.fromISO8601DateLoose(chars); } else if (Dates.isShortDate(chars)) {
@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 () ) ); } }
if ( checkDate ) { Date date = null; if ( Dates.isISO8601QuickCheck ( buffer, startIndex, endIndex ) ) { if (Dates.isJsonDate ( buffer,startIndex, endIndex )) { date = Dates.fromJsonDate ( buffer, startIndex, endIndex );
if ( checkDate ) { Date date = null; if ( Dates.isISO8601QuickCheck ( buffer, startIndex, endIndex ) ) { if (Dates.isJsonDate ( buffer,startIndex, endIndex )) { date = Dates.fromJsonDate ( buffer, startIndex, endIndex );