Java examples for java.sql:Oracle
get Oracle Date Time Second Pattern
import java.io.Serializable; import java.util.Locale; public class Main{ static final String timeWithSecOracleFormat = "HH24:MI:SS"; public static String getOracleDateTimeSecPattern(String languageCode) { String pattern = getOracleDatePattern(languageCode); pattern = pattern + " " + timeWithSecOracleFormat; return pattern; }// w ww. j ava 2s .c o m 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; } 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); } } }