Java Code Examples for java.text.spi.DateFormatProvider

The following examples show how to use java.text.spi.DateFormatProvider. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TencentKona-8   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 2
Source Project: jdk8u_jdk   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 3
Source Project: jdk8u60   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 4
Source Project: hottub   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 5
Source Project: jdk8u-jdk   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 6
Source Project: jdk8u-dev-jdk   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 7
Source Project: Bytecoder   Source File: DateFormat.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 8
Source Project: openjdk-jdk9   Source File: DateFormat.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 2
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * ignored if flags is 1
 * @param flags either 1 for a time format, 2 for a date format,
 * or 3 for a date/time format
 * @param loc the locale for the format
 */
private static DateFormat get(int timeStyle, int dateStyle,
                              int flags, Locale loc) {
    if ((flags & 1) != 0) {
        if (timeStyle < 0 || timeStyle > 3) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
    } else {
        timeStyle = -1;
    }
    if ((flags & 2) != 0) {
        if (dateStyle < 0 || dateStyle > 3) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }
    } else {
        dateStyle = -1;
    }

    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
    if (dateFormat == null) {
        dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
    }
    return dateFormat;
}
 
Example 9
Source Project: openjdk-8   Source File: JSpinner.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale loc) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    LocaleResources lr = adapter.getLocaleResources(loc);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
    }
    return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
 
Example 10
Source Project: jdk1.8-source-analysis   Source File: JSpinner.java    License: Apache License 2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale loc) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    LocaleResources lr = adapter.getLocaleResources(loc);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
    }
    return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
 
Example 11
Source Project: jdk8u-jdk   Source File: Bug6989440.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example 12
Source Project: dragonwell8_jdk   Source File: DateFormat.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
    DateFormatProvider provider = adapter.getDateFormatProvider();
    DateFormat dateFormat;
    if (timeStyle == -1) {
        dateFormat = provider.getDateInstance(dateStyle, loc);
    } else {
        if (dateStyle == -1) {
            dateFormat = provider.getTimeInstance(timeStyle, loc);
        } else {
            dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
        }
    }
    return dateFormat;
}
 
Example 13
@Override
public DateFormatProvider getDateFormatProvider() {
    if (dateFormatProvider == null) {
        DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(),
                                                getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (dateFormatProvider == null) {
                dateFormatProvider = provider;
            }
        }
    }
    return dateFormatProvider;
}
 
Example 14
Source Project: Java8CN   Source File: DateFormat.java    License: Apache License 2.0 5 votes vote down vote up
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
    DateFormatProvider provider = adapter.getDateFormatProvider();
    DateFormat dateFormat;
    if (timeStyle == -1) {
        dateFormat = provider.getDateInstance(dateStyle, loc);
    } else {
        if (dateStyle == -1) {
            dateFormat = provider.getTimeInstance(timeStyle, loc);
        } else {
            dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
        }
    }
    return dateFormat;
}
 
Example 15
Source Project: openjdk-8-source   Source File: Bug6989440.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example 16
@Override
public DateFormatProvider getDateFormatProvider() {
    if (dateFormatProvider == null) {
        DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(),
                                                getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (dateFormatProvider == null) {
                dateFormatProvider = provider;
            }
        }
    }
    return dateFormatProvider;
}
 
Example 17
Source Project: jdk8u-jdk   Source File: JSpinner.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale loc) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    LocaleResources lr = adapter.getLocaleResources(loc);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
    }
    return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
 
Example 18
Source Project: TencentKona-8   Source File: DateFormat.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
    DateFormatProvider provider = adapter.getDateFormatProvider();
    DateFormat dateFormat;
    if (timeStyle == -1) {
        dateFormat = provider.getDateInstance(dateStyle, loc);
    } else {
        if (dateStyle == -1) {
            dateFormat = provider.getTimeInstance(timeStyle, loc);
        } else {
            dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
        }
    }
    return dateFormat;
}
 
Example 19
@Override
public DateFormatProvider getDateFormatProvider() {
    if (dateFormatProvider == null) {
        DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(),
                                                getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (dateFormatProvider == null) {
                dateFormatProvider = provider;
            }
        }
    }
    return dateFormatProvider;
}
 
Example 20
Source Project: TencentKona-8   Source File: Bug6989440.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example 21
Source Project: jdk8u60   Source File: DateFormat.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
    DateFormatProvider provider = adapter.getDateFormatProvider();
    DateFormat dateFormat;
    if (timeStyle == -1) {
        dateFormat = provider.getDateInstance(dateStyle, loc);
    } else {
        if (dateStyle == -1) {
            dateFormat = provider.getTimeInstance(timeStyle, loc);
        } else {
            dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
        }
    }
    return dateFormat;
}
 
Example 22
Source Project: jdk8u-dev-jdk   Source File: Bug6989440.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example 23
Source Project: jdk8u60   Source File: JSpinner.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale loc) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    LocaleResources lr = adapter.getLocaleResources(loc);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
    }
    return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
 
Example 24
Source Project: jdk8u60   Source File: Bug6989440.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example 25
Source Project: jdk8u_jdk   Source File: DateFormat.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
    DateFormatProvider provider = adapter.getDateFormatProvider();
    DateFormat dateFormat;
    if (timeStyle == -1) {
        dateFormat = provider.getDateInstance(dateStyle, loc);
    } else {
        if (dateStyle == -1) {
            dateFormat = provider.getTimeInstance(timeStyle, loc);
        } else {
            dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
        }
    }
    return dateFormat;
}
 
Example 26
Source Project: JDKSourceCode1.8   Source File: JSpinner.java    License: MIT License 5 votes vote down vote up
private static String getDefaultPattern(Locale loc) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    LocaleResources lr = adapter.getLocaleResources(loc);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
    }
    return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
 
Example 27
Source Project: Java8CN   Source File: JSpinner.java    License: Apache License 2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale loc) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
    LocaleResources lr = adapter.getLocaleResources(loc);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
    }
    return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
 
Example 28
@Override
public DateFormatProvider getDateFormatProvider() {
    if (dateFormatProvider == null) {
        DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(),
                                                getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (dateFormatProvider == null) {
                dateFormatProvider = provider;
            }
        }
    }
    return dateFormatProvider;
}
 
Example 29
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
    DateFormatProvider provider = adapter.getDateFormatProvider();
    DateFormat dateFormat;
    if (timeStyle == -1) {
        dateFormat = provider.getDateInstance(dateStyle, loc);
    } else {
        if (dateStyle == -1) {
            dateFormat = provider.getTimeInstance(timeStyle, loc);
        } else {
            dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
        }
    }
    return dateFormat;
}
 
Example 30
@Override
public DateFormatProvider getDateFormatProvider() {
    if (dateFormatProvider == null) {
        DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(),
                                                getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (dateFormatProvider == null) {
                dateFormatProvider = provider;
            }
        }
    }
    return dateFormatProvider;
}