Java yyyy 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;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final SimpleDateFormat defaultFormater = new SimpleDateFormat("yyyyMMdd");
    private static final SimpleDateFormat customizedFormater = new SimpleDateFormat("yyyyMMdd");

    public static String format(Date date, String pattern) {
        synchronized (customizedFormater) {
            if (null != pattern && !"".equals(pattern.trim())) {
                customizedFormater.applyPattern(pattern);
            } else {
                throw new IllegalArgumentException("pattern can not be empty");
            }//www  .  j  a  va2  s.c  o m
            return customizedFormater.format(date);
        }
    }

    public static String format(Date date) {
        synchronized (defaultFormater) {
            return defaultFormater.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)
  9. format(Date date)