Java Utililty Methods Date Now

List of utility methods to do Date Now

Description

The list of methods to do Date Now are organized into topic(s).

Method

StringgetCurrentDateTimeForShow()
get Current Date Time For Show
return showDateFormat.format(new Date());
StringgetCurrentDateTimeISO8601()
get Current Date Time ISO
DecimalFormat df = new DecimalFormat("00");
Calendar calendar = GregorianCalendar.getInstance();
int hour = calendar.get(Calendar.AM_PM) == Calendar.AM ? calendar.get(Calendar.HOUR)
        : calendar.get(Calendar.HOUR) + 12;
return (new Integer(calendar.get(Calendar.YEAR))).toString() + "-"
        + df.format(calendar.get(Calendar.MONTH) + 1) + "-" + df.format(calendar.get(Calendar.DATE)) + " "
        + df.format(hour) + ":" + df.format(calendar.get(Calendar.MINUTE)) + ":"
        + df.format(calendar.get(Calendar.SECOND));
...
DategetCurrentDateTimeObj(String dateTime, String format)
get Current Date Time Obj
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.parse(dateTime);
StringgetCurrentDateTimeString()
get Current Date Time String
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
return getDefaultFormatedDate(calendar.getTime().getTime());
StringgetCurrentDateTimeString(String returnFormat)
get Current Date Time String
DateFormat dateFormat = new SimpleDateFormat(returnFormat);
Date date = new Date();
String dateString = dateFormat.format(date);
dateString = dateString.replace("/", "");
dateString = dateString.replace(" ", "");
dateString = dateString.replace(":", "");
dateString = dateString.replace(".", "");
return dateString;
...
StringgetCurrentDateTimeStringValue()
Gets current Time in xsd:dateTime format.
Calendar cal = Calendar.getInstance();
Date thisDate = cal.getTime();
SimpleDateFormat formatterDate = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatterTime = new SimpleDateFormat("HH:mm:ss");
String currDate = formatterDate.format(thisDate) + "T" + formatterTime.format(thisDate);
return currDate;
StringgetCurrentDateToString(String pattern)
add by zhaoliguo format current date to string by input pattern
Date date = new Date();
return getDateToString(date, pattern);
StringgetCurrentDateWithDot()
get Current Date With Dot
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy.MM.dd",
        java.util.Locale.KOREA);
return dateFormat.format(new java.util.Date());
StringgetCurrentDay()
get Current Day
java.util.Date NowDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat("dd");
return formatter.format(NowDate);
StringgetCurrentDay()

Method: get current day[year-month-day] type string

return formatCurrentTime(YEAR_MONTH_DAY);