Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentTime(long currentTime) { SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); Date curDate = new Date(currentTime); String currentDate = formatter.format(curDate); return currentDate; } public static String getCurrentTime() { SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return simpleDate.format(new Date()); } public static String getCurrentTime(String pattern) { SimpleDateFormat simpleDate = new SimpleDateFormat(pattern); return simpleDate.format(new Date()); } }