Java Date to String dateTimeToZero(Date date)

Here you can find the source of dateTimeToZero(Date date)

Description

date Time To Zero

License

Open Source License

Declaration

public static final Date dateTimeToZero(Date date) 

Method Source Code


//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static final String dateFormat = "yyyy-MM-dd";

    public static final Date dateTimeToZero(Date date) {
        if (date == null) {
            return null;
        }/* w w w .j a va 2 s  .co m*/
        return strToDtSimpleFormat(dateFormat(date));
    }

    public static final Date strToDtSimpleFormat(String strDate) {
        if (strDate == null) {
            return null;
        }

        try {
            return getFormat(dateFormat).parse(strDate);
        } catch (Exception e) {
        }

        return null;
    }

    public static final String dateFormat(Date date) {
        if (date == null) {
            return "";
        }
        return getFormat(dateFormat).format(date);
    }

    public static final DateFormat getFormat(String format) {
        return new SimpleDateFormat(format);
    }

    public static final String format(Date date, String formate) {
        if (date == null) {
            return "";
        }
        return getFormat(formate).format(date);
    }

    public static final String format(Long dateTmie, String formate) {
        Date date = new Date(dateTmie);
        return getFormat(formate).format(date);
    }
}

Related

  1. date2StringPattern(Date value, String pattern)
  2. Date2StringSec(Date date)
  3. datetime(Date date)
  4. dateTime2String(Date dateTime, DateFormat dateFormat)
  5. dateTimeISO(final java.util.Date date)
  6. dateTo14String(Date date)
  7. dateToBOMCStrDate(Date date)
  8. dateToCalendar(Date fecha, String formato)
  9. dateToDateString(Date date, Locale locale)