Here you can find the source of getCurrentDate()
public static String getCurrentDate()
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { public static final String DEFAULT_TIMEZONE = "Aisa/Shanghai"; public static final String FORMAT_DATE_YYYY_MM_DD = "yyyy-MM-dd"; /**/*from w ww. j av a2 s . c om*/ * Get current date, format yyyy/MM/dd. * * @return */ public static String getCurrentDate() { return formatDate(getCurrentTimestamp()); } public static String formatDate(Date iDate) { return formatDate(iDate, FORMAT_DATE_YYYY_MM_DD); } public static String formatDate(Date iDate, String sDatePattern) { if (iDate == null) { return null; } SimpleDateFormat oFormat = new SimpleDateFormat(sDatePattern); oFormat.setLenient(false); return oFormat.format(iDate); } public static Timestamp getCurrentTimestamp() { return new Timestamp(getDate().getTime()); } public static Date getDate() { TimeZone tz = TimeZone.getTimeZone(DEFAULT_TIMEZONE); Calendar calendar = Calendar.getInstance(tz); return calendar.getTime(); } }