Java Code Examples for sun.util.calendar.CalendarUtils#sprintf0d()

The following examples show how to use sun.util.calendar.CalendarUtils#sprintf0d() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalendarAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
String toTimeString() {
    StringBuffer sb = new StringBuffer();
    CalendarUtils.sprintf0d(sb, cal.get(HOUR_OF_DAY), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(MINUTE), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(SECOND),2 ).append('.');
    CalendarUtils.sprintf0d(sb, cal.get(MILLISECOND), 3);
    int zoneOffset = cal.get(ZONE_OFFSET) + cal.get(DST_OFFSET);
    if (zoneOffset == 0) {
        sb.append('Z');
    } else {
        int offset;
        char sign;
        if (zoneOffset > 0) {
            offset = zoneOffset;
            sign = '+';
        } else {
            offset = -zoneOffset;
            sign = '-';
        }
        offset /= 60000;
        sb.append(sign);
        CalendarUtils.sprintf0d(sb, offset / 60, 2);
        CalendarUtils.sprintf0d(sb, offset % 60, 2);
    }
    return sb.toString();
}
 
Example 2
Source File: CalendarAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
String toTimeString() {
    StringBuffer sb = new StringBuffer();
    CalendarUtils.sprintf0d(sb, cal.get(HOUR_OF_DAY), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(MINUTE), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(SECOND),2 ).append('.');
    CalendarUtils.sprintf0d(sb, cal.get(MILLISECOND), 3);
    int zoneOffset = cal.get(ZONE_OFFSET) + cal.get(DST_OFFSET);
    if (zoneOffset == 0) {
        sb.append('Z');
    } else {
        int offset;
        char sign;
        if (zoneOffset > 0) {
            offset = zoneOffset;
            sign = '+';
        } else {
            offset = -zoneOffset;
            sign = '-';
        }
        offset /= 60000;
        sb.append(sign);
        CalendarUtils.sprintf0d(sb, offset / 60, 2);
        CalendarUtils.sprintf0d(sb, offset % 60, 2);
    }
    return sb.toString();
}
 
Example 3
Source File: CalendarAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
String toTimeString() {
    StringBuffer sb = new StringBuffer();
    CalendarUtils.sprintf0d(sb, cal.get(HOUR_OF_DAY), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(MINUTE), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(SECOND),2 ).append('.');
    CalendarUtils.sprintf0d(sb, cal.get(MILLISECOND), 3);
    int zoneOffset = cal.get(ZONE_OFFSET) + cal.get(DST_OFFSET);
    if (zoneOffset == 0) {
        sb.append('Z');
    } else {
        int offset;
        char sign;
        if (zoneOffset > 0) {
            offset = zoneOffset;
            sign = '+';
        } else {
            offset = -zoneOffset;
            sign = '-';
        }
        offset /= 60000;
        sb.append(sign);
        CalendarUtils.sprintf0d(sb, offset / 60, 2);
        CalendarUtils.sprintf0d(sb, offset % 60, 2);
    }
    return sb.toString();
}
 
Example 4
Source File: CalendarAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
String toDateString() {
    StringBuffer sb = new StringBuffer();
    String[] eraNames = null;
    switch (type) {
    case GREGORIAN:
        eraNames = new String[] { "BCE", "" };
        break;

    case BUDDHIST:
        eraNames = new String[] { "Before BE", "BE"};
        break;

    case JAPANESE:
        eraNames = new String[] {
            "BeforeMeiji",
            "Meiji",
            "Taisho",
            "Showa",
            "Heisei",
            "Reiwa"
        };
        break;
    }

    sb.append(eraNames[cal.get(ERA)]);
    if (sb.length() > 0)
        sb.append(' ');
    CalendarUtils.sprintf0d(sb, cal.get(YEAR), 4).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(MONTH)+1, 2).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(DAY_OF_MONTH), 2);
    return sb.toString();
}
 
Example 5
Source File: CalendarAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
String toDateString() {
    StringBuffer sb = new StringBuffer();
    String[] eraNames = null;
    switch (type) {
    case GREGORIAN:
        eraNames = new String[] { "BCE", "" };
        break;

    case BUDDHIST:
        eraNames = new String[] { "Before BE", "BE"};
        break;

    case JAPANESE:
        eraNames = new String[] {
            "BeforeMeiji",
            "Meiji",
            "Taisho",
            "Showa",
            "Heisei",
            "Reiwa"
        };
        break;
    }

    sb.append(eraNames[cal.get(ERA)]);
    if (sb.length() > 0)
        sb.append(' ');
    CalendarUtils.sprintf0d(sb, cal.get(YEAR), 4).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(MONTH)+1, 2).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(DAY_OF_MONTH), 2);
    return sb.toString();
}
 
Example 6
Source File: CalendarAdapter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
String toDateString() {
    StringBuffer sb = new StringBuffer();
    String[] eraNames = null;
    switch (type) {
    case GREGORIAN:
        eraNames = new String[] { "BCE", "" };
        break;

    case BUDDHIST:
        eraNames = new String[] { "Before BE", "BE"};
        break;

    case JAPANESE:
        eraNames = new String[] {
            "BeforeMeiji",
            "Meiji",
            "Taisho",
            "Showa",
            "Heisei",
            "Reiwa"
        };
        break;
    }

    sb.append(eraNames[cal.get(ERA)]);
    if (sb.length() > 0)
        sb.append(' ');
    CalendarUtils.sprintf0d(sb, cal.get(YEAR), 4).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(MONTH)+1, 2).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(DAY_OF_MONTH), 2);
    return sb.toString();
}
 
Example 7
Source File: CalendarAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
String toDateString() {
    StringBuffer sb = new StringBuffer();
    String[] eraNames = null;
    switch (type) {
    case GREGORIAN:
        eraNames = new String[] { "BCE", "" };
        break;

    case BUDDHIST:
        eraNames = new String[] { "Before BE", "BE"};
        break;

    case JAPANESE:
        eraNames = new String[] {
            "BeforeMeiji",
            "Meiji",
            "Taisho",
            "Showa",
            "Heisei",
            "Reiwa"
        };
        break;
    }

    sb.append(eraNames[cal.get(ERA)]);
    if (sb.length() > 0)
        sb.append(' ');
    CalendarUtils.sprintf0d(sb, cal.get(YEAR), 4).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(MONTH)+1, 2).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(DAY_OF_MONTH), 2);
    return sb.toString();
}
 
Example 8
Source File: Date.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 9
Source File: Date.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 10
Source File: Date.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 11
Source File: Date.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 12
Source File: Date.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this {@code Date} object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month ({@code 1} through {@code 31}),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month ({@code Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec}).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day ({@code 00} through {@code 23}),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour ({@code 00} through
 *     {@code 59}), as two decimal digits.
 * <li><i>ss</i> is the second within the minute ({@code 00} through
 *     {@code 61}), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "{@code GMT}" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by {@code DateFormat.format(Date date)}, using a
 * GMT {@code TimeZone}.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 13
Source File: Date.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a string representation of this {@code Date} object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month ({@code 1} through {@code 31}),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month ({@code Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec}).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day ({@code 00} through {@code 23}),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour ({@code 00} through
 *     {@code 59}), as two decimal digits.
 * <li><i>ss</i> is the second within the minute ({@code 00} through
 *     {@code 61}), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "{@code GMT}" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by {@code DateFormat.format(Date date)}, using a
 * GMT {@code TimeZone}.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 14
Source File: Date.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 15
Source File: Date.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 16
Source File: Date.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote<pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 17
Source File: Date.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 18
Source File: Date.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 19
Source File: Date.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a string representation of this <tt>Date</tt> object of
 * the form:
 * <blockquote><pre>
 * d mon yyyy hh:mm:ss GMT</pre></blockquote>
 * where:<ul>
 * <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>),
 *     as one or two decimal digits.
 * <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul,
 *     Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><i>yyyy</i> is the year, as four decimal digits.
 * <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>),
 *     as two decimal digits.
 * <li><i>mm</i> is the minute within the hour (<tt>00</tt> through
 *     <tt>59</tt>), as two decimal digits.
 * <li><i>ss</i> is the second within the minute (<tt>00</tt> through
 *     <tt>61</tt>), as two decimal digits.
 * <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate
 *     Greenwich Mean Time.
 * </ul><p>
 * The result does not depend on the local time zone.
 *
 * @return  a string representation of this date, using the Internet GMT
 *          conventions.
 * @see     java.text.DateFormat
 * @see     java.util.Date#toString()
 * @see     java.util.Date#toLocaleString()
 * @deprecated As of JDK version 1.1,
 * replaced by <code>DateFormat.format(Date date)</code>, using a
 * GMT <code>TimeZone</code>.
 */
@Deprecated
public String toGMTString() {
    // d MMM yyyy HH:mm:ss 'GMT'
    long t = getTime();
    BaseCalendar cal = getCalendarSystem(t);
    BaseCalendar.Date date =
        (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
    StringBuilder sb = new StringBuilder(32);
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    sb.append(date.getYear()).append(' ');                            // yyyy
    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');      // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');    // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);                // ss
    sb.append(" GMT");                                                // ' GMT'
    return sb.toString();
}
 
Example 20
Source File: Time.java    From beihu-boot with Apache License 2.0 3 votes vote down vote up
/**
 * Converts this <code>Time</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 *  hh:mm:ss SSS</pre></blockquote>
 * where:<ul>
 * <li><tt>hh</tt> is the hour of the day (<tt>00</tt> through
 * <tt>23</tt>), as two decimal digits.
 * <li><tt>mm</tt> is the minute within the hour (<tt>00</tt> through
 * <tt>59</tt>), as two decimal digits.
 * <li><tt>ss</tt> is the second within the minute (<tt>00</tt> through
 * <tt>61</tt>, as two decimal digits.
 * <li><tt>SSS</tt> is the milliseconds within the millisecond (<tt>000</tt> through
 * <tt>999</tt>, as three decimal digits.
 * </ul>
 *
 * @return a string representation of this date.
 * @see Date#toString()
 * @see Date#toLocaleString()
 * @see Date#toGMTString()
 */
@Override
public String toString() {
    // "HH:mm:ss SSS";
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(fastTime);
    StringBuilder sb = new StringBuilder(12);

    Integer[] mods = mod();
    CalendarUtils.sprintf0d(sb, mods[0], 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, mods[1], 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, mods[2], 2).append(' '); // ss
    CalendarUtils.sprintf0d(sb, mods[3], 3); // SSS
    return sb.toString();
}