Here you can find the source of toDateFormat(String dateFormat, TimeZone tz, Locale locale)
Parameter | Description |
---|---|
dateFormat | optional format string |
tz | a parameter |
locale | can be null if dateFormat is not null |
public static DateFormat toDateFormat(String dateFormat, 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 { /**// ww w . ja v a2 s .c om * Returns an initialized DateFormat object. * * @param dateFormat * optional format string * @param tz * @param locale * can be null if dateFormat is not null * @return DateFormat object */ public static DateFormat toDateFormat(String dateFormat, TimeZone tz, Locale locale) { DateFormat df = null; if (dateFormat == null) { df = DateFormat.getDateInstance(DateFormat.SHORT, locale); } else { df = new SimpleDateFormat(dateFormat); } df.setTimeZone(tz); return df; } }