The list of methods to do Date Create are organized into topic(s).
Date
add24HtoDate(Date date) add Hto Date
Calendar cal = new GregorianCalendar();
cal.setTime(date);
cal.setTimeInMillis(date.getTime());
cal.add(Calendar.DATE, 1);
return new Date(cal.getTimeInMillis());
Date
addTimeToDate(Date date, Date time) Adds specified time of day to a date.
String dateAndTime = formatDateNoTime(date) + " " + formatTime(time);
ParsePosition pos = new ParsePosition(0);
Date result = dateFormatter1.parse(dateAndTime, pos);
if ((result != null) && (pos.getIndex() < dateAndTime.length()))
result = null;
return result;
Date
buildDate(int y, int m, int d) build Date
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, y);
cal.set(Calendar.MONTH, m - 1);
cal.set(Calendar.DAY_OF_MONTH, d);
return cal.getTime();
Date
buildDate(String dateAsString) build Date
try {
return DATE_FORMATTER.parse(dateAsString);
} catch (Exception e) {
throw new RuntimeException("Failed to parse date - " + dateAsString, e);
SimpleDateFormat
buildDateFormat(final String pattern) Get a SimpleDateFormat object by given pattern.
SimpleDateFormat simpleDateFormat = simpleDateFormatCache.get();
if (simpleDateFormat == null) {
simpleDateFormat = new SimpleDateFormat();
simpleDateFormatCache.set(simpleDateFormat);
simpleDateFormat.applyPattern(pattern);
return simpleDateFormat;
Date
buildDateTime(String curDate, String curTime, String meridiem) Build the date object according to the date and time value from the page.
Date newDate = null;
if (curDate != null && !"".equals(curDate.trim()) && curTime != null && !"".equals(curTime.trim())) {
String dateToParse = curDate + " " + curTime + " " + meridiem;
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
try {
newDate = format.parse(dateToParse);
} catch (ParseException paex) {
newDate = null;
...
String
buildDateTimeUTC(Calendar cal) Builds a
dateTime value in UTC from a
Calendar value.
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
f.setTimeZone(TimeZone.getTimeZone("UTC"));
return f.format(cal.getTime());
Date
castToDate(Object value) cast To Date
if (value == null) {
return null;
if (value instanceof Calendar) {
return ((Calendar) value).getTime();
if (value instanceof Date) {
return (Date) value;
...