Here you can find the source of getCurrentTime(String formatter)
Parameter | Description |
---|---|
formatter | : yyyyMMddHHmmss |
public static String getCurrentTime(String formatter)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.TimeZone; public class Main { private final static String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; /**/*from w w w . ja v a 2 s . c om*/ * get system time with a default date format * @return String */ public static String getCurrentTime() { return getCurrentTime(getDefaultFormat()); } /** * get system time with a formatter * @param formatter : yyyyMMddHHmmss * @return String */ public static String getCurrentTime(String formatter) { SimpleDateFormat fmt = new SimpleDateFormat(formatter); fmt.setTimeZone(getTimeZone()); return fmt.format(new java.util.Date(System.currentTimeMillis())); } /** * get default date format : yyyyMMdd, yyyy-MM-dd HH:mm:ss * @return String */ public static String getDefaultFormat() { return DEFAULT_DATE_FORMAT; //return BasePropManager.getBaseProperties("Environment").getString("date.formatter", DEFAULT_DATE_FORMAT); } /** * get default SimpleTimeZone (System Properties) * @return SimpleTimeZone */ public static TimeZone getTimeZone() { return TimeZone.getDefault(); } }