/** * Serialize time to general date text. Date values are formatted in W3C XML Schema standard * format as CCYY-MM-DD, with optional leading sign included if necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * @return converted date text * @throws IllegalArgumentException on conversion error */ public static String serializeDate(long time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); formatYearMonthDay(time + TIME_BASE, buff); return buff.toString(); }
/** * Serialize time to standard text. Time values are formatted in W3C XML Schema standard format * as hh:mm:ss, with optional trailing seconds decimal, as necessary. The standard conversion * does not append a time zone indication. * * @param time time to be converted * @return converted time text * @throws IllegalArgumentException on conversion error */ public static String serializeSqlTime(Time time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); long t = time.getTime(); t += TimeZone.getDefault().getOffset(t); int extra = formatYearMonthDay(t + TIME_BASE, buff); buff.delete(0, buff.length()); serializeTime(extra, buff); return buff.toString(); }
/** * Serialize time to general dateTime text. Date values are formatted in W3C XML Schema standard * format as CCYY-MM-DDThh:mm:ss, with optional leading sign and trailing seconds decimal, as * necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * @param zone flag for trailing 'Z' to be appended to indicate UTC * @return converted dateTime text * @throws IllegalArgumentException on conversion error */ public static String serializeDateTime(long time, boolean zone) throws IllegalArgumentException { // start with the year, month, and day StringBuffer buff = new StringBuffer(25); int extra = formatYearMonthDay(time + TIME_BASE, buff); // append the time for full form buff.append('T'); serializeTime(extra, buff); // return full text with optional trailing zone indicator if (zone) { buff.append('Z'); } return buff.toString(); }
/** * Serialize time to general date text. Date values are formatted in W3C * XML Schema standard format as CCYY-MM-DD, with optional leading sign * included if necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * * @return converted date text * * @throws IllegalArgumentException on conversion error */ public static String serializeDate(long time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); formatYearMonthDay(time + TIME_BASE, buff); return buff.toString(); }
/** * Serialize time to general date text. Date values are formatted in W3C * XML Schema standard format as CCYY-MM-DD, with optional leading sign * included if necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * * @return converted date text * * @throws IllegalArgumentException on conversion error */ public static String serializeDate(long time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); formatYearMonthDay(time + TIME_BASE, buff); return buff.toString(); }
/** * Serialize time to standard text. Time values are formatted in W3C XML * Schema standard format as hh:mm:ss, with optional trailing seconds * decimal, as necessary. The standard conversion does not append a time * zone indication. * * @param time time to be converted * * @return converted time text * * @throws IllegalArgumentException on conversion error */ public static String serializeSqlTime(Time time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); long t = time.getTime(); t += TimeZone.getDefault().getOffset(t); int extra = formatYearMonthDay(t + TIME_BASE, buff); buff.delete(0, buff.length()); serializeTime(extra, buff); return buff.toString(); }
/** * Serialize time to standard text. Time values are formatted in W3C XML * Schema standard format as hh:mm:ss, with optional trailing seconds * decimal, as necessary. The standard conversion does not append a time * zone indication. * * @param time time to be converted * * @return converted time text * * @throws IllegalArgumentException on conversion error */ public static String serializeSqlTime(Time time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); long t = time.getTime(); t += TimeZone.getDefault().getOffset(t); int extra = formatYearMonthDay(t + TIME_BASE, buff); buff.delete(0, buff.length()); serializeTime(extra, buff); return buff.toString(); }
/** * Serialize time to general dateTime text. Date values are formatted in * W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss, with optional * leading sign and trailing seconds decimal, as necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * @param zone flag for trailing 'Z' to be appended to indicate UTC * * @return converted dateTime text * * @throws IllegalArgumentException on conversion error */ public static String serializeDateTime(long time, boolean zone) throws IllegalArgumentException { // start with the year, month, and day StringBuffer buff = new StringBuffer(25); int extra = formatYearMonthDay(time + TIME_BASE, buff); // append the time for full form buff.append('T'); serializeTime(extra, buff); // return full text with optional trailing zone indicator if (zone) { buff.append('Z'); } return buff.toString(); }
/** * Serialize time to general dateTime text. Date values are formatted in * W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss, with optional * leading sign and trailing seconds decimal, as necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * @param zone flag for trailing 'Z' to be appended to indicate UTC * * @return converted dateTime text * * @throws IllegalArgumentException on conversion error */ public static String serializeDateTime(long time, boolean zone) throws IllegalArgumentException { // start with the year, month, and day StringBuffer buff = new StringBuffer(25); int extra = formatYearMonthDay(time + TIME_BASE, buff); // append the time for full form buff.append('T'); serializeTime(extra, buff); // return full text with optional trailing zone indicator if (zone) { buff.append('Z'); } return buff.toString(); }