Java Parse Date parseDate(Date date)

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

Description

Parses a Date to a string using #DATE_STORAGE_FORMAT .

License

Apache License

Parameter

Parameter Description
date The Date to parse.

Return

The parsed String.

Declaration

public static String parseDate(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    /**//from ww  w .  j ava2 s .c  o  m
     * The storage format for parsing dates.
     */
    public static final String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";

    /**
     * Parses a Date to a string using {@link #DATE_STORAGE_FORMAT}.
     *
     * <p>
     * The default storage format is config-friendly, so it may be used in YamlConfig.</p>
     * <p>
     * Parsing <i>null</i> returns "never".</p>
     *
     * @param date The Date to parse.
     * @return The parsed String.
     * @see #parseString(String)
     */
    public static String parseDate(Date date) {
        if (date == null) {
            return "never";
        }
        return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).format(date);
    }
}

Related

  1. parseDate(@Nonnull String stringDate)
  2. parseDate(@Nullable String value)
  3. parseDate(Date date)
  4. parseDate(Date date)
  5. parseDate(Date date)
  6. parseDate(Date date)
  7. parseDate(Date date)
  8. parseDate(Date date, int style, Locale local, boolean withTime)
  9. parseDate(Date date, String format)