Here you can find the source of today()
public static Date today()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** this date format for internal use. **/ private static final String DATEFORMAT_YYYYMMDD = "yyyyMMdd"; /**//from w w w. j av a2s .c om * Get the current date value. * * <pre> * DateUtils.today() = 20120629 * </pre> * * @return Date, default pattern yyyyMMdd. */ public static Date today() { return today(DATEFORMAT_YYYYMMDD); } /** * To get the current time value in accordance with the format specified. * * <pre> * <code> * DateUtils.today("yyyyMMdd") = 20120629 * </code> * </pre> * * @param pattern date pattern to truncate the time. * @return Date */ public static Date today(String pattern) { Date date = getDate(); if (pattern == null) { return date; } try { DateFormat df = getDateFormat(pattern); date = df.parse(df.format(getDate())); } catch (Exception e) { return date; } return date; } /** * get date. * * @return Date. */ public static Date getDate() { return new Date(); } /** * return date format with Locale US. * * @param pattern date format pattern. * @return DateFormat */ public static DateFormat getDateFormat(String pattern) { return new SimpleDateFormat(pattern, Locale.US); } }