Java Hour Format format(Date date)

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

Description

Format a date object.

License

LGPL

Parameter

Parameter Description
date the date

Return

the string representation

Declaration

public static String format(Date date) 

Method Source Code

//package com.java2s;
/*/*from ww w  .j a va2  s  .  co  m*/
 * Copyright 2008-2014, David Karnok 
 * The file is part of the Open Imperium Galactica project.
 * 
 * The code should be distributed under the LGPL license.
 * See http://www.gnu.org/licenses/lgpl.html for details.
 */

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;

import java.util.TimeZone;

public class Main {
    /** The date formatter. */
    public static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            sdf.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("GMT")));
            return sdf;
        }
    };

    /**
     * Format a date object.
     * @param date the date
     * @return the string representation
     */
    public static String format(Date date) {
        return DATE_FORMAT.get().format(date);
    }
}

Related

  1. format(Date date)
  2. format(Date date)
  3. format(Date date)
  4. format(Date date)
  5. format(Date date)
  6. format(Date date)
  7. format(Date date)
  8. format(Date date, String dateFormat)
  9. format(Date date, String format)