Java Now printNow()

Here you can find the source of printNow()

Description

print Now

License

Apache License

Declaration

public static String printNow() 

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 printNow() {
        return toString(currentDate());
    }//from ww  w.j a v  a 2s . co  m

    public static String toString(Date now) {
        SimpleDateFormat formatTime = new SimpleDateFormat(PATNER_DEFAULT);
        if (now == null)
            return "";
        return formatTime.format(now);
    }

    public static Date currentDate() {
        return new Date();
    }

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

Related

  1. nowStr()
  2. nowString(String pattern)
  3. nowString(String pattern)
  4. nowTime(String formartStr)
  5. nowTime(String format)
  6. stringDate(Date now)
  7. subNow()
  8. toStr2(Date now)
  9. toString(Date now)