Java examples for java.sql:Oracle
get Oracle Date Time Pattern
import java.io.Serializable; import java.util.Locale; public class Main{ static final String timeOracleFormat = "HH24:MI"; public static String getOracleDateTimePattern(String languageCode) { String pattern = getOracleDatePattern(languageCode); pattern = pattern + " " + timeOracleFormat; return pattern; }/* w w w. j a v a 2 s . co 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); } } }