Java Date to String convertDateToStr(Date d, String format)

Here you can find the source of convertDateToStr(Date d, String format)

Description

convert Date To Str

License

Open Source License

Declaration

public static String convertDateToStr(Date d, String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String convertDateToStr(Date d, String format) {
        SimpleDateFormat simpledateformat = new SimpleDateFormat(format);
        String s;//from  w w  w  .  ja  v  a2s.c o m
        try {
            s = simpledateformat.format(d).toString();
            return s;
        } catch (Exception e) {
            s = "1900-01-01";
        }
        return s;
    }
}

Related

  1. convertDate2String(Date date)
  2. convertDate2String8(Date time)
  3. convertDateTimeToString(Date date)
  4. convertDateTo(Date date, String patternToUse)
  5. convertDateToServerTimeZoneDate(DateFormat formatter, String timeZoneName, long milliSecond)
  6. convertDateToStr(Date date, String format)
  7. convertDateToString(final Date datum, final boolean withDay)
  8. convertDateToString(java.util.Date dt, String pattern)
  9. convertDateToString(String dateFormat, Date date)