Java Now toString(Date now)

Here you can find the source of toString(Date now)

Description

to String

License

Apache License

Declaration

public static String toString(Date now) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

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

    public static String toString(Date now) {
        SimpleDateFormat formatTime = new SimpleDateFormat(PATNER_DEFAULT);
        if (now == null)
            return "";
        return formatTime.format(now);
    }/*from  w w  w.  java 2  s  .co m*/

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

Related

  1. nowTime(String format)
  2. printNow()
  3. stringDate(Date now)
  4. subNow()
  5. toStr2(Date now)