Java Date to String dateToStr(Date date)

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

Description

date To Str

License

Apache License

Declaration

public static String dateToStr(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String dateToStr(Date date) {
        String s = "";
        if (date == null) {
            return "";
        }// w w  w  .  ja  v  a 2 s . c o m

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            s = sdf.format(date);
        } catch (Exception e) {

        }

        return s;
    }
}

Related

  1. dateToISODate(Date date)
  2. dateToOracleDateString(Date date)
  3. dateToRelativeTime(Date date)
  4. dateToRFC1123(Date date)
  5. dateToRFC3339(Date d)
  6. dateToStr(Date date)
  7. dateToStr(Date date)
  8. dateToStr(Date date)
  9. dateToStr(Date date, int type)