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

StringtoDate(final Date date)
to Date
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);
return date != null ? sdf.format(date) : null;
StringtoDate(int date)
to Date
return new SimpleDateFormat("dd.MM.yyyy").format(new Date(date * 1000L));
StringtoDate(int flag, Date... date)
to Date
SimpleDateFormat simple = null;
if (flag == 0)
    simple = new SimpleDateFormat(FORMAT_0);
else if (flag == 1)
    simple = new SimpleDateFormat(FORMAT_1);
else
    simple = new SimpleDateFormat(FORMAT_2);
if (date.length > 0) {
...
StringtoDate(long lastModified)
to Date
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm:ss");
return sdf.format(lastModified);
DatetoDate(long segundos)
to Date
long horas = segundos / 3600;
segundos = segundos % 3600;
long minutos = segundos / 60;
segundos = segundos % 60;
DecimalFormat df = new DecimalFormat("00");
String sfecha = df.format(horas) + ":" + df.format(minutos) + ":" + df.format(segundos);
Date fecha = timeToDate(sfecha);
return fecha;
...
StringtoDate(long time)
Convert friendly date time format
return formatDateTime.format(time);
DatetoDate(long time)
Returns the given long value as a date object.
return new Date(time);
ObjecttoDate(Object o)
to Date
SimpleDateFormat sdf = null;
try {
    if (o instanceof Date) {
        return o;
    } else if (o instanceof String) {
        String text = ((String) o).trim();
        int len = text.length();
        if (len == d_cst_fmt.length()) {
...
DateToDate(Object o)
To Date
return ToDate(ToString(o));
DatetoDate(Object object)
to Date
String in = object.toString();
Date date;
DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
try {
    date = formater.parse(in);
    return date;
} catch (ParseException e) {
    return null;
...