Java Date to String dateToStr(Date date, String formatstr)

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

Description

date To Str

License

Apache License

Declaration

public static String dateToStr(Date date, String formatstr) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss";

    public static String dateToStr(Date date) {
        SimpleDateFormat format = new SimpleDateFormat(yyyyMMddHHmmss);
        return format.format(date);
    }/*from   w  w w .ja  va  2s. c o m*/

    public static String dateToStr(Date date, String formatstr) {
        SimpleDateFormat format = new SimpleDateFormat(formatstr);
        return format.format(date);
    }
}

Related

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