Java Date Now currentDate2String()

Here you can find the source of currentDate2String()

Description

current Date String

License

Open Source License

Declaration

public static String currentDate2String() 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String currentDate2String() {
        return date2String(new Date());
    }/*from   w w  w. j av a 2 s . c  o m*/

    public static String date2String(Date date) {
        return date2String(date, "yyyy-MM-dd HH:mm:ss.SSS");
    }

    public static String date2String(Date date, String pattern) {
        if (date == null) {
            return null;
        }
        return (new SimpleDateFormat(pattern)).format(date);
    }
}

Related

  1. currentDate(int dateStyle)
  2. currentDate(String format)
  3. currentDate(String format, Locale locale)
  4. currentDate(String format, String locale)
  5. currentDate2String()
  6. currentDate_DDMMYY()
  7. currentDateAsString()
  8. currentDatePath(String basePath)
  9. currentDateStr()