Java Date Create toDateText(Date date)

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

Description

to Date Text

License

Apache License

Declaration

public static String toDateText(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    /**//from   w  w w  .  j a v a  2 s  .co m
     * Default date format
     */
    public static final String DATE_FORMAT = "yyyy-MM-dd";

    public static String toDateText(Date date) {
        return toDateText(date, DATE_FORMAT);
    }

    public static String toDateText(Date date, String pattern) {
        if (date == null || pattern == null) {
            return null;
        }
        DateFormat dateFormat = createDateFormat(pattern);
        return dateFormat.format(date);
    }

    private static DateFormat createDateFormat(String pattern) {
        return new SimpleDateFormat(pattern, Locale.SIMPLIFIED_CHINESE);
    }
}

Related

  1. toDateList(Collection list)
  2. toDateQueryFormat(Date value)
  3. toDateStr(Date d)
  4. ToDateStr(Date dt)
  5. toDateStr(Object o)
  6. toDateTime(Date date)
  7. toDatetime(long value)