Search in sources :

Example 1 with GregorianCalendar

use of com.ibm.icu.util.GregorianCalendar in project es6draft by anba.

the class DateTimeFormatObject method createDateFormat.

private DateFormat createDateFormat() {
    ULocale locale = ULocale.forLanguageTag(this.locale);
    // calendar and numberingSystem are already handled in language-tag
    // assert locale.getKeywordValue("calendar").equals(calendar);
    // assert locale.getKeywordValue("numbers").equals(numberingSystem);
    SimpleDateFormat dateFormat = new SimpleDateFormat(pattern.get(), locale);
    if (timeZone != null) {
        dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone));
    }
    Calendar calendar = dateFormat.getCalendar();
    if (calendar instanceof GregorianCalendar) {
        // format uses a proleptic Gregorian calendar with no year 0
        GregorianCalendar gregorian = (GregorianCalendar) calendar;
        gregorian.setGregorianChange(new Date(Long.MIN_VALUE));
    }
    return dateFormat;
}
Also used : ULocale(com.ibm.icu.util.ULocale) Calendar(com.ibm.icu.util.Calendar) GregorianCalendar(com.ibm.icu.util.GregorianCalendar) GregorianCalendar(com.ibm.icu.util.GregorianCalendar) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

SimpleDateFormat (com.ibm.icu.text.SimpleDateFormat)1 Calendar (com.ibm.icu.util.Calendar)1 GregorianCalendar (com.ibm.icu.util.GregorianCalendar)1 ULocale (com.ibm.icu.util.ULocale)1 Date (java.util.Date)1