Here you can find the source of today()
public static String today()
//package com.java2s; /****************************************************************************** * @File name : DateUtil.java/*from ww w .j ava 2 s.c o m*/ * * @Package : com.envision.envservice.common.util * * @Author : xuyang.li * * @Date : 2015?10?27? ????5:09:25 * * @Description : ????? * * @Copyright Notice: * Copyright (c) 2015 Envision, Inc. All Rights Reserved. * This software is published under the terms of the Envision Software * License version 1.0, a copy of which has been included with this * distribution in the LICENSE.txt file. * * * ---------------------------------------------------------------------------- * Date Who Version Comments * 2015?10?27? ????5:09:25 xuyang.li 1.0 Initial Version *****************************************************************************/ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Objects; public class Main { /** * Format: yyyy-MM-dd */ public static final String YYYYMMDD = "yyyy-MM-dd"; private static final String DEFAULT_FORMAT = YYYYMMDD; public static String today() { return today(YYYYMMDD); } public static String today(String format) { return new SimpleDateFormat(format).format(new Date()); } public static String format(Date date) { return format(date, DEFAULT_FORMAT); } public static String format(Date date, String format) { Objects.requireNonNull(date); Objects.requireNonNull(format); return new SimpleDateFormat(format).format(date); } }