Here you can find the source of getToday()
public static String getToday()
//package com.java2s; import java.util.Calendar; import java.util.TimeZone; import java.text.SimpleDateFormat; public class Main { private static SimpleDateFormat defaultDateFormatter; /**//from w w w . j a va 2 s . c om * Get date string as format of "yyyy-MM-dd" * @return */ public static String getToday() { return getDefaultDateFormatter().format(getCalendar().getTime()); } /** * Get simple date formatter with default time zone of GMT+8 * @return simple date formatter */ public static SimpleDateFormat getDefaultDateFormatter() { if (defaultDateFormatter == null) { defaultDateFormatter = new SimpleDateFormat("yyyy-MM-dd"); defaultDateFormatter.setTimeZone(getDefaultTimeZone()); } return defaultDateFormatter; } /** * Get calendar instance with default time zone of GMT+8 * @return Calendar instance */ public static Calendar getCalendar() { TimeZone.setDefault(getDefaultTimeZone()); return Calendar.getInstance(); } /** * Get default time zone of China * @return default time zone */ public static TimeZone getDefaultTimeZone() { return TimeZone.getTimeZone("GMT+8"); } }