Java Date to String date2Str(Date aDate)

Here you can find the source of date2Str(Date aDate)

Description

date Str

License

Open Source License

Declaration

public static final String date2Str(Date aDate) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String date2Str(Date aDate) {
        SimpleDateFormat df = null;
        String returnValue = "";

        if (aDate != null) {
            df = new SimpleDateFormat("yyyy-MM-dd");
            returnValue = df.format(aDate);
        }//from  w w w  .  j av  a2s  . c  om

        return (returnValue);
    }

    public static final String date2Str(String pattern, Date aDate) {
        SimpleDateFormat df = null;
        String returnValue = "";

        if (aDate != null) {
            df = new SimpleDateFormat(pattern);
            returnValue = df.format(aDate);
        }
        return (returnValue);
    }
}

Related

  1. convertToString(Date date, String style)
  2. convertToString(java.util.Date date)
  3. convertToString(String format, Date date)
  4. date2str(Calendar c)
  5. date2Str(Calendar c, String format)
  6. date2Str(Date date)
  7. Date2Str(Date date)
  8. date2Str(Date date)
  9. date2Str(Date date, String dateFormat)