Here you can find the source of getDateFormatSymbols(Locale locale)
Parameter | Description |
---|---|
locale | the Locale used to get the correct DateFormatSymbols |
public static final DateFormatSymbols getDateFormatSymbols(Locale locale)
//package com.java2s; /*//from www .j av a 2 s .c o m * Copyright 2001-2012 Stephen Colebourne * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.lang.reflect.Method; import java.text.DateFormatSymbols; import java.util.Locale; public class Main { /** * Gets the {@link DateFormatSymbols} based on the given locale. * <p> * If JDK 6 or newer is being used, DateFormatSymbols.getInstance(locale) will * be used in order to allow the use of locales defined as extensions. * Otherwise, new DateFormatSymbols(locale) will be used. * See JDK 6 {@link DateFormatSymbols} for further information. * * @param locale the {@link Locale} used to get the correct {@link DateFormatSymbols} * @return the symbols * @since 2.0 */ public static final DateFormatSymbols getDateFormatSymbols(Locale locale) { try { Method method = DateFormatSymbols.class.getMethod( "getInstance", new Class[] { Locale.class }); return (DateFormatSymbols) method.invoke(null, new Object[] { locale }); } catch (Exception ex) { return new DateFormatSymbols(locale); } } }