Java Hour Format format(Date date)

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

Description

format

License

Open Source License

Declaration

public static String format(Date date) 

Method Source Code


//package com.java2s;
import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Main {
    private static Lock lock = new ReentrantLock();

    public static String format(Date date) {
        return getDateFormat().format(date);
    }/* ww w  .  ja va  2s  .  com*/

    /**
     * Returns a formatter for ISO 8601 format as described at http://www.cl.cam.ac.uk/~mgk25/iso-time.html
     * @return
     */
    public static final DateFormat getDateFormat() {
        lock.lock();
        try {
            TimeZone tz = TimeZone.getTimeZone("UTC");
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            df.setTimeZone(tz);
            return df;
        } finally {
            lock.unlock();
        }
    }
}

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)
  9. format(Date date)