Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getCurTime(String format) { long now = System.currentTimeMillis(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(now); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(calendar.getTime()); } }