Java examples for java.sql:Oracle
get Oracle Date Pattern
import java.io.Serializable; import java.util.Locale; public class Main{ public static String getOracleDatePattern(String languageCode) { String pattern = getDatePattern(getLocale(languageCode)); pattern = pattern.replaceAll("yyyy", "YYYY"); //pattern = pattern.replaceAll( "MM", "MM" ); pattern = pattern.replaceAll("dd", "DD"); return pattern; }// w ww . j av a 2 s .co m public static String getDatePattern(Locale locale) { // Get ISO standard pattern with formatted (DD, MM, YYYY) if (locale != null && locale.toString().equalsIgnoreCase("zh_HK")) { locale = new Locale("zh", "CN"); } DateFormatProperties props = new DateFormatProperties(); props.setDateStyle("short"); props.setLocale(locale); props.setTimeStyle("HH:mm:ss"); CustomDateFormatter customFormatter = new CustomDateFormatter(props); return customFormatter.getDatePattern(); } private static Locale getLocale(String languageCode) { int index = languageCode.indexOf('_'); if (index == -1) { return new Locale(languageCode); } else { String language = languageCode.substring(0, index); String country = languageCode.substring(index + 1); return new Locale(language, country); } } }