Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss"; /** * Get String current time. {@link FTimeUtil#DEFAULT_FORMAT} * * @return */ public static String getCurrentTime() { return getCurrentTime(DEFAULT_FORMAT); } /** * Get String current time. * * @param format use format from FDataUtil. {@link FTimeUtil#FORMAT_1} * @return */ public static String getCurrentTime(String format) { SimpleDateFormat df = new SimpleDateFormat(format); return df.format(new Date(System.currentTimeMillis())); } }