Java Code Examples for sun.util.calendar.BaseCalendar#SUNDAY

The following examples show how to use sun.util.calendar.BaseCalendar#SUNDAY . 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: Date.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 2
Source File: Date.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 3
Source File: Date.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this {@code Date} object to a {@code String}
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li>{@code dow} is the day of the week ({@code Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat}).
 * <li>{@code mon} is the month ({@code Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec}).
 * <li>{@code dd} is the day of the month ({@code 01} through
 *     {@code 31}), as two decimal digits.
 * <li>{@code hh} is the hour of the day ({@code 00} through
 *     {@code 23}), as two decimal digits.
 * <li>{@code mm} is the minute within the hour ({@code 00} through
 *     {@code 59}), as two decimal digits.
 * <li>{@code ss} is the second within the minute ({@code 00} through
 *     {@code 61}, as two decimal digits.
 * <li>{@code zzz} is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method {@code parse}. If time zone
 *     information is not available, then {@code zzz} is empty -
 *     that is, it consists of no characters at all.
 * <li>{@code yyyy} is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 4
Source File: Date.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Converts this {@code Date} object to a {@code String}
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li>{@code dow} is the day of the week ({@code Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat}).
 * <li>{@code mon} is the month ({@code Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec}).
 * <li>{@code dd} is the day of the month ({@code 01} through
 *     {@code 31}), as two decimal digits.
 * <li>{@code hh} is the hour of the day ({@code 00} through
 *     {@code 23}), as two decimal digits.
 * <li>{@code mm} is the minute within the hour ({@code 00} through
 *     {@code 59}), as two decimal digits.
 * <li>{@code ss} is the second within the minute ({@code 00} through
 *     {@code 61}, as two decimal digits.
 * <li>{@code zzz} is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method {@code parse}. If time zone
 *     information is not available, then {@code zzz} is empty -
 *     that is, it consists of no characters at all.
 * <li>{@code yyyy} is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 5
Source File: Date.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 6
Source File: Date.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 7
Source File: Date.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 8
Source File: Date.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    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
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 10
Source File: Date.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Converts this <code>Date</code> object to a <code>String</code>
 * of the form:
 * <blockquote><pre>
 * dow mon dd hh:mm:ss zzz yyyy</pre></blockquote>
 * where:<ul>
 * <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed,
 *     Thu, Fri, Sat</tt>).
 * <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun,
 *     Jul, Aug, Sep, Oct, Nov, Dec</tt>).
 * <li><tt>dd</tt> is the day of the month (<tt>01</tt> through
 *     <tt>31</tt>), as two decimal digits.
 * <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>zzz</tt> is the time zone (and may reflect daylight saving
 *     time). Standard time zone abbreviations include those
 *     recognized by the method <tt>parse</tt>. If time zone
 *     information is not available, then <tt>zzz</tt> is empty -
 *     that is, it consists of no characters at all.
 * <li><tt>yyyy</tt> is the year, as four decimal digits.
 * </ul>
 *
 * @return  a string representation of this date.
 * @see     java.util.Date#toLocaleString()
 * @see     java.util.Date#toGMTString()
 */
public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == BaseCalendar.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd

    CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
}
 
Example 11
Source File: Date.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 12
Source File: Date.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 13
Source File: Date.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 14
Source File: Date.java    From j2objc with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 15
Source File: Date.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 16
Source File: Date.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 17
Source File: Date.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 18
Source File: Date.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value ({@code 0} = Sunday, {@code 1} = Monday,
 * {@code 2} = Tuesday, {@code 3} = Wednesday, {@code 4} =
 * Thursday, {@code 5} = Friday, {@code 6} = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this {@code Date} object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by {@code Calendar.get(Calendar.DAY_OF_WEEK)}.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 19
Source File: Date.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
 
Example 20
Source File: Date.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the day of the week represented by this date. The
 * returned value (<tt>0</tt> = Sunday, <tt>1</tt> = Monday,
 * <tt>2</tt> = Tuesday, <tt>3</tt> = Wednesday, <tt>4</tt> =
 * Thursday, <tt>5</tt> = Friday, <tt>6</tt> = Saturday)
 * represents the day of the week that contains or begins with
 * the instant in time represented by this <tt>Date</tt> object,
 * as interpreted in the local time zone.
 *
 * @return  the day of the week represented by this date.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.get(Calendar.DAY_OF_WEEK)</code>.
 */
@Deprecated
public int getDay() {
    return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}