Java yyyy format6chars(Date date)

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

Description

formatchars

License

Apache License

Declaration

public static String format6chars(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String format6chars = "yyyyMM";

    public static String format6chars(Date date) {
        return format(date, get6charDateFormat());
    }//from  w ww.j ava2s . c o  m

    /**
     * Returns a string the represents the passed-in date parsed
     * according to the passed-in format.  Returns an empty string
     * if the date or the format is null.
     **/
    public static String format(Date aDate, SimpleDateFormat aFormat) {
        if (aDate == null || aFormat == null) {
            return "";
        }
        synchronized (aFormat) {
            return aFormat.format(aDate);
        }
    }

    public static SimpleDateFormat get6charDateFormat() {
        return new SimpleDateFormat(format6chars);
    }
}

Related

  1. format(Object value, String pattern)
  2. format(ResourceBundle idioma, Date date)
  3. format(String dateString)
  4. format(String oldPattern, String newPattern, String data)
  5. format2(Date data)
  6. format6chars(Date date, TimeZone tz)
  7. formatAddDate(String src, String pattern, int amount)
  8. formatarData(Date data)
  9. formatarData(String pattern, Date data)