Here you can find the source of getTimestamp()
public static String getTimestamp()
//package com.java2s; /*// w ww . j a v a 2s . c o m * ??????? (C) 2000-2007 ????? <TanMenglong@gmail.com> * * ????????Mozilla Public Licene1.1????????????????????????????? * http://www.mozilla.org/MPL/MPL-1.1.html */ import java.util.*; import java.text.SimpleDateFormat; public class Main { private static Calendar cal = Calendar.getInstance(); private static SimpleDateFormat sdf = new SimpleDateFormat(); public static String getTimestamp() { return getDate("yyyy-MM-dd HH:mm:ss"); } public static String getDate() { sdf.applyPattern("yyyy-MM-dd"); String date = sdf.format(cal.getTime()); return date; } public static String getDate(String patten) { sdf.applyPattern(patten); String date = sdf.format(cal.getTime()); return date; } }