Java Date Format dateFormatToString(String source, String format)

Here you can find the source of dateFormatToString(String source, String format)

Description

date Format To String

License

Open Source License

Declaration

public static String dateFormatToString(String source, String format) 

Method Source Code


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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static String dateFormatToString(String source, String format) {
        if (source == null || "".equals(source))
            return null;
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        dateFormat.setLenient(false);/*www .j  a  v  a 2 s. co m*/
        return dateFormat.format(source);
    }

    public static String dateFormatToString(Date source, String format) {
        if (source == null || "".equals(source))
            return null;
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        dateFormat.setLenient(false);
        return dateFormat.format(source);
    }
}

Related

  1. dateFormatString(Date date)
  2. dateFormatted(Date date)
  3. dateFormatter(String dateFormat)
  4. dateFormatTime(final Date date)
  5. dateFormatToString(Date date, String format)
  6. dateFormatUTC()
  7. dateTime2Str(Date date, String pattern)
  8. dateTime2String(Date value)
  9. dateTime2StringFs(Date date)