/** * Serialize time to general gYearMonth text. Date values are formatted in W3C XML Schema * standard format as CCYY-MM, with optional leading sign included if necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * @return converted gYearMonth text * @throws IllegalArgumentException on conversion error */ public static String serializeYearMonth(long time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); formatYearMonth(time + TIME_BASE, buff); return buff.toString(); }
/** * Format time in milliseconds to year number, month number, and day number. The resulting year * number format is consistent with W3C XML Schema definitions, using a minimum of four digits * for the year and exactly two digits each for the month and day. * * @param value time in milliseconds to be converted (from 1 C.E.) * @param buff text formatting buffer * @return number of milliseconds into day */ protected static int formatYearMonthDay(long value, StringBuffer buff) { // convert year and month long extra = formatYearMonth(value, buff); // append the day of month int day = (int) (extra / MSPERDAY) + 1; buff.append('-'); formatTwoDigits(day, buff); // return excess of milliseconds into day return (int) (extra % MSPERDAY); }
/** * Serialize time to general gYearMonth text. Date values are formatted in * W3C XML Schema standard format as CCYY-MM, with optional leading sign * included if necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * * @return converted gYearMonth text * * @throws IllegalArgumentException on conversion error */ public static String serializeYearMonth(long time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); formatYearMonth(time + TIME_BASE, buff); return buff.toString(); }
/** * Serialize time to general gYearMonth text. Date values are formatted in * W3C XML Schema standard format as CCYY-MM, with optional leading sign * included if necessary. * * @param time time to be converted, as milliseconds from January 1, 1970 * * @return converted gYearMonth text * * @throws IllegalArgumentException on conversion error */ public static String serializeYearMonth(long time) throws IllegalArgumentException { StringBuffer buff = new StringBuffer(12); formatYearMonth(time + TIME_BASE, buff); return buff.toString(); }
/** * Format time in milliseconds to year number, month number, and day * number. The resulting year number format is consistent with W3C XML * Schema definitions, using a minimum of four digits for the year and * exactly two digits each for the month and day. * * @param value time in milliseconds to be converted (from 1 C.E.) * @param buff text formatting buffer * * @return number of milliseconds into day */ protected static int formatYearMonthDay(long value, StringBuffer buff) { // convert year and month long extra = formatYearMonth(value, buff); // append the day of month int day = (int) (extra / MSPERDAY) + 1; buff.append('-'); formatTwoDigits(day, buff); // return excess of milliseconds into day return (int) (extra % MSPERDAY); }
/** * Format time in milliseconds to year number, month number, and day * number. The resulting year number format is consistent with W3C XML * Schema definitions, using a minimum of four digits for the year and * exactly two digits each for the month and day. * * @param value time in milliseconds to be converted (from 1 C.E.) * @param buff text formatting buffer * * @return number of milliseconds into day */ protected static int formatYearMonthDay(long value, StringBuffer buff) { // convert year and month long extra = formatYearMonth(value, buff); // append the day of month int day = (int) (extra / MSPERDAY) + 1; buff.append('-'); formatTwoDigits(day, buff); // return excess of milliseconds into day return (int) (extra % MSPERDAY); }