/** * Convert a timestamp string into a Date. * * @param value the timestamp String * @return the parsed timestamp * @exception FieldConvertError raised if timestamp is an incorrect format. */ public static Date convert(String value) throws FieldConvertError { verifyFormat(value); long timeOffset = (parseLong(value.substring(9, 11)) * 3600000L) + (parseLong(value.substring(12, 14)) * 60000L) + (parseLong(value.substring(15, LENGTH_INCL_SECONDS)) * 1000L); if (value.length() == LENGTH_INCL_MILLIS || value.length() == LENGTH_INCL_MICROS || value.length() == LENGTH_INCL_NANOS || value.length() == LENGTH_INCL_PICOS) { // accept up to picosenconds but parse only up to milliseconds timeOffset += parseLong(value.substring(18, LENGTH_INCL_MILLIS)); } return new Date(getMillisForDay(value) + timeOffset); }
/** * Convert a timestamp string into a Date. * Date has up to millisecond precision. * * @param value the timestamp String * @return the parsed timestamp * @exception FieldConvertError raised if timestamp is an incorrect format. */ public static Date convert(String value) throws FieldConvertError { verifyFormat(value); long timeOffset = getTimeOffsetSeconds(value); if (value.length() >= LENGTH_INCL_MILLIS) { // format has already been verified // accept up to picosenconds but parse only up to milliseconds timeOffset += parseLong(value.substring(18, LENGTH_INCL_MILLIS)); } return new Date(getMillisForDay(value) + timeOffset); }
/** * Convert a timestamp string into a Date. * Date has up to millisecond precision. * * @param value the timestamp String * @return the parsed timestamp * @exception FieldConvertError raised if timestamp is an incorrect format. */ public static Date convert(String value) throws FieldConvertError { verifyFormat(value); long timeOffset = getTimeOffsetSeconds(value); if (value.length() >= LENGTH_INCL_MILLIS) { // format has already been verified // accept up to picosenconds but parse only up to milliseconds timeOffset += parseLong(value.substring(18, LENGTH_INCL_MILLIS)); } return new Date(getMillisForDay(value) + timeOffset); }