Java Date to String dateToStr(Date source)

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

Description

date To Str

License

Open Source License

Declaration

public static String dateToStr(Date source) 

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 dateToStr(Date source, String pattern) {
        String result = null;//from w  w w. j  a  v  a  2  s  .co m
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        result = format.format(source);
        return result;
    }

    public static String dateToStr(Date source) {
        return dateToStr(source, "yyyy-MM-dd HH:mm:ss");
    }
}

Related

  1. dateToStr(Date date, int type)
  2. dateToStr(Date date, String format)
  3. dateToStr(Date date, String format)
  4. dateToStr(Date date, String formatstr)
  5. dateToStr(Date date, String formatType)
  6. datetoStr2(Date date)
  7. datetoStr3(Date date)
  8. dateToStrIBInput(Date date)
  9. dateToString(Date d)