Java Time Now getNow(boolean ifdatetime)

Here you can find the source of getNow(boolean ifdatetime)

Description

get Now

License

Apache License

Declaration

public static String getNow(boolean ifdatetime) 

Method Source Code

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

public class Main {
    /**//from w w  w. j  a  v  a2s . c o  m
     * yyyy-MM-dd
     */
    public static final String DATE_FORMAT = "yyyy-MM-dd";
    /**
     * yyyy-MM-dd HH:mm:ss
     */
    public static final String STRING_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getNow(boolean ifdatetime) {
        java.util.Date dd = new java.util.Date();
        java.text.SimpleDateFormat df = null;
        String rtn = "";
        if (ifdatetime) {
            df = new java.text.SimpleDateFormat(STRING_DATE_FORMAT);
        } else {
            df = new java.text.SimpleDateFormat(DATE_FORMAT);
        }
        rtn = df.format(dd);
        return rtn;
    }
}

Related

  1. getNow()
  2. getNow()
  3. getNow()
  4. getNow()
  5. getNow()
  6. getNow(final String format)
  7. getNow(String format)
  8. getNowAsNICSDate()
  9. getNowAsString()