get Date Time Hour Pattern - Java java.util

Java examples for java.util:Date Parse

Description

get Date Time Hour Pattern

Demo Code


import java.io.Serializable;
import java.util.Locale;

public class Main{
    static final String timeFormat12Hour = "hh:mm";
    public static String getDateTime12HourPattern(Locale locale) {
        String pattern = getDatePattern(locale);
        pattern = pattern + " " + timeFormat12Hour;
        return pattern;
    }//from  w ww.ja v a2s  . c  om
    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();
    }
}

Related Tutorials