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

StringgetCurrentDateAndTime()
get Current Date And Time
return getFormattedDateAndTime(new Date());
StringgetCurrentDateAndTimeFormat()
get Current Date And Time Format
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm z");
Date currentDate = new Date(System.currentTimeMillis());
String myFormattedDate = myFormatter.format(currentDate);
return myFormattedDate;
StringgetCurrentDateAsNiceString()
get Current Date As Nice String
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
Date now = new Date();
return formatter.format(now);
byte[]getCurrentDateAsNumericEncodedByteArray()
get Current Date As Numeric Encoded Byte Array
SimpleDateFormat format = new SimpleDateFormat("yyMMdd");
return fromHexString(format.format(new Date()));
StringgetCurrentDateAsString()
get Current Date As String
return DEFAULT_DATE_FORMAT.format(Calendar.getInstance().getTime());
StringgetCurrentDateAsString(DateFormat df)
get Current Date As String
return df.format(new Date());
StringgetCurrentDateAsString(String timestampFormat)
Get the current date timestamp as a string
Format formatter;
Date date = new Date();
formatter = new SimpleDateFormat(timestampFormat);
return formatter.format(date).toString();
StringgetCurrentDateByString(String datePattern)
get Current Date By String
return new SimpleDateFormat(datePattern).format(System.currentTimeMillis());
StringgetCurrentDateDBFormat()
get Current Date DB Format
Date current = new Date(System.currentTimeMillis());
return dateFormatDB.format(current);
StringgetCurrentDateFormat()
get current date
return formatDate(new Date());