Here you can find the source of toTimeFormat(String timeFormat, TimeZone tz, Locale locale)
Parameter | Description |
---|---|
timeFormat | optional format string |
tz | a parameter |
locale | can be null if timeFormat is not null |
public static DateFormat toTimeFormat(String timeFormat, TimeZone tz, Locale locale)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; public class Main { /**//from w ww. j a va 2 s . co m * Returns an initialized DateFormat object. * * @param timeFormat * optional format string * @param tz * @param locale * can be null if timeFormat is not null * @return DateFormat object */ public static DateFormat toTimeFormat(String timeFormat, TimeZone tz, Locale locale) { DateFormat df = null; if (timeFormat == null) { df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); } else { df = new SimpleDateFormat(timeFormat); } df.setTimeZone(tz); return df; } }