Java Utililty Methods Date Create

List of utility methods to do Date Create

Description

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

Method

DatetoDate(Object value)
to Date
String stringValue = String.valueOf(value);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
return dateFormat.parse(stringValue);
StringtoDateFormat(Date date)
Returns a string in standard PDF date format representing the specified date (in the default timezone).
Calendar c = Calendar.getInstance();
c.setTime(date);
return toPDFDateFormat(c);
DatetoDateFromLong(Long time)
to Date From Long
try {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String str = formatter.format(time);
    Date date = formatter.parse(str);
    return date;
} catch (ParseException e) {
    e.printStackTrace();
    return null;
...
StringtoDateHeader(long value)
to Date Header
final SimpleDateFormat[] formats = DATE_FORMATS.get();
return formats[0].format(new Date(value));
StringtoDateList(Collection list)
Converts a collection of values to an R compatible list.
return toDateList(list, "''yyyy-MM-dd''");
StringtoDateQueryFormat(Date value)
Transforms a Date instance into a String using the default date parser.
return new SimpleDateFormat(ISO8601_FMT).format(value);
StringtoDateStr(Date d)
to Date Str
if (d == null) {
    return null;
String ret = null;
try {
    ret = new SimpleDateFormat(IOS_DATE_FORMAT).format(d);
} catch (Exception e) {
    ret = new SimpleDateFormat(IOS_DATE_FORMAT_OLD).format(d);
...
StringToDateStr(Date dt)
To Date Str
if (dt == null)
    return "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(dt);
StringtoDateStr(Object o)
to Date Str
return o == null ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) o);
StringtoDateText(Date date)
to Date Text
return toDateText(date, DATE_FORMAT);