Java Time Now getNowStr()

Here you can find the source of getNowStr()

Description

get Now Str

License

Open Source License

Declaration

public static String getNowStr() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

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

    public static String getNowStr() {
        return dateToStr();
    }/*  w  w w. j  av  a  2s .  c om*/

    public static String dateToStr(Date date) {
        if (date == null) {
            return "";
        }
        return dateToString(date, NORMAL_PATTERN);
    }

    public static String dateToStr() {
        return dateToStr(new Date());
    }

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

    @Deprecated
    public static String dateToString(Date date) {
        return dateToStr(date);
    }
}

Related

  1. getNowInputDate()
  2. getNowOfDateByFormat(String format)
  3. getNowPatch()
  4. getNowSinceHour()
  5. getNowStr()
  6. getNowStr()
  7. getNowStrDateVerbose()
  8. getNowString()
  9. getNowString()