Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String currentTime() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(new Date()); } public static String currentTime(String format) { SimpleDateFormat df = new SimpleDateFormat(format); return df.format(new Date()); } }