Here you can find the source of getCurrentTimeInString(String format)
Parameter | Description |
---|---|
format | a parameter |
public static String getCurrentTimeInString(String format)
//package com.java2s; import java.text.*; import java.util.*; public class Main { /**/*from w w w . j av a 2 s .c om*/ * @param format * @return String * Current time in String. */ public static String getCurrentTimeInString(String format) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } /** * format. * @param input input * @param replace replace * @return String */ public static String format(String input, String... replace) { String str = ""; Formatter formatter = new Formatter(); try { str = formatter.format(input, (Object[]) replace).toString(); } finally { formatter.close(); } return str; } }