Java Year Format getyyyy_MM_dd(Date date)

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

Description

getyyyMdd

License

Open Source License

Declaration

public static String getyyyy_MM_dd(Date date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    public static String getyyyy_MM_dd(Date date) {
        if (date == null)
            return "";
        return sdf.format(date);
    }//from w  w  w .ja va2s  .c  om

    public static Date getyyyy_MM_dd(String date) {
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
        }
        return new Date();
    }
}

Related

  1. getYear(String pFormattedDate)
  2. getYYMMDD()
  3. getYYMMDD(int i)
  4. getYYYY()
  5. getYYYY(java.util.Date date)
  6. getyyyy_MM_dd2(String date)
  7. getYYYYMM()
  8. getYYYYMM(final Date date, final String separator)
  9. getYYYYMMDD(Date date)