Here you can find the source of getCurrentDateTime(String format)
public static String getCurrentDateTime(String format)
//package com.java2s; //License from project: LGPL import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentDateTime(String format) { return millisToDateTime(System.currentTimeMillis(), format); }//from w ww . ja va 2 s . c om public static String millisToDateTime(long millis, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.format(new Date(millis)); } }