Java Date to String dateToHuman(Date date)

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

Description

Convert a date to a humanly readable date.

License

Open Source License

Parameter

Parameter Description
date - date in date format

Return

string - The date in string format

Declaration

public static String dateToHuman(Date date) 

Method Source Code

//package com.java2s;
/*// w  w  w . j  av  a 2 s  . com
    
 Copyright IBM Corp. 2012, 2016
 This file is part of Anomaly Detection Engine for Linux Logs (ADE).

 ADE is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 ADE is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with ADE.  If not, see <http://www.gnu.org/licenses/>.
    
 */

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    private static ThreadLocal<DateFormat> m_date = new ThreadLocal<DateFormat>() {
        @Override
        protected DateFormat initialValue() {
            return new SimpleDateFormat("d MMM yyyy",
                    new Locale("en", "US"));
        }
    };

    /**
     * Convert a date to a humanly readable date.
     * 
     * @param date - date in date format
     * @return string - The date in string format
     */
    public static String dateToHuman(Date date) {
        if (date == null) {
            return "missing";
        }
        return m_date.get().format(date);
    }
}

Related

  1. dateToFMDate(Date date)
  2. dateToFormattedString(Date toFormat)
  3. dateToHHmmStr(Date date)
  4. dateToHMTime(Date date)
  5. dateToHttpDateString(Date d)
  6. DateToInteger(Date date)
  7. dateToIso(Date d)
  8. dateToIso8601String(Date date)
  9. dateToISODate(Date date)