Java Today getTodayString()

Here you can find the source of getTodayString()

Description

get Today String

License

Apache License

Declaration

public static String getTodayString() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/*from w  w w. j a v  a  2  s.c  om*/
     * yyyy-MM-dd HH:mm:ss
     */
    public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getTodayString() {
        return format(new Date());
    }

    public static String getTodayString(String dateFormat) {
        return format(new Date(), dateFormat);
    }

    public static String format(Date date) {
        return format(date, DATETIME_FORMAT);
    }

    public static String format(Date date, String dateFormat) {
        if (date != null) {
            SimpleDateFormat format = new SimpleDateFormat(dateFormat);
            String dateString = format.format(date);
            return dateString;
        }
        return null;
    }
}

Related

  1. getTodaysDate(String dateFormat)
  2. getTodayStart()
  3. getTodayStr()
  4. getTodayStr()
  5. getTodayString()
  6. getTodayString()
  7. getTodayString()
  8. getTodayTime()
  9. getTodayTimeForDB()