Here you can find the source of currentTimestamp2String(String pattern)
public static String currentTimestamp2String(String pattern)
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss"; public static String currentTimestamp2String(String pattern) { return timestamp2String(currentTimestamp(), pattern); }//w w w . j av a 2 s. com public static String timestamp2String(Timestamp timestamp, String pattern) { if (timestamp == null) { throw new java.lang.IllegalArgumentException("timestamp null illegal"); } if (pattern == null || pattern.equals("")) { pattern = PATTERN_STANDARD; } SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(new Date(timestamp.getTime())); } public static Timestamp currentTimestamp() { return new Timestamp(new Date().getTime()); } }