Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static String getDateTime() { String paramFormat = "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat(paramFormat); return sdf.format(System.currentTimeMillis()).toString(); } public static String getDateTime(String time) { String paramFormat = "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat(paramFormat); return sdf.format(time).toString(); } }