Java Today today()

Here you can find the source of today()

Description

today

License

Apache License

Declaration

public static String today() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String today() {
        return formatDate(new Date(), "yyyy-MM-dd");
    }/* w  w w  . ja  v a  2  s.co m*/

    public static String formatDate(Date date) {
        if (date == null) {
            return "";
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(date);
    }

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

Related

  1. today()
  2. today()
  3. today()
  4. today()
  5. today()
  6. today()
  7. today()
  8. today()
  9. toDay(final String dateString)