Here you can find the source of getTodayStr()
Parameter | Description |
---|---|
date | date |
static public String getTodayStr() throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**//from ww w. j av a2 s.co m * format pattern : yyyy-MM-dd */ public static final SimpleDateFormat FORMAT_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd"); /** * getToday get todat string with format YYYY-MM-DD from a Date object * * @param date * date * @return String */ static public String getTodayStr() throws ParseException { Calendar calendar = Calendar.getInstance(); return getDateStr(calendar.getTime()); } /** * getDateStr get a string with format YYYY-MM-DD from a Date object * * @param date * date * @return String */ static public String getDateStr(Date date) { return FORMAT_YYYY_MM_DD.format(date); } static public String format(Date date, String formatText) throws Exception { SimpleDateFormat format = new SimpleDateFormat(formatText); return format.format(date); } }