Java Today getToday()

Here you can find the source of getToday()

Description

get Today

License

Open Source License

Declaration

public static String getToday() 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.*;

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

    public static String getToday() {
        return formatDate(new Date());
    }/*from   ww w.ja  v a 2 s  .  c  o m*/

    public static String getToday(String pattern) {
        return formatDateTime(new Date(), pattern);
    }

    public static String formatDate(Date d) {
        return formatDateTime(d, DATE_PATTERN);
    }

    public static String formatDateTime(Date d) {
        return formatDateTime(d, DATETIME_PATTERN);
    }

    public static String formatDateTime(Date d, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(d);
    }
}

Related

  1. getToday()
  2. getToday()
  3. getToday()
  4. getToday()
  5. getToday()
  6. getToday()
  7. getToday()
  8. getToday(boolean ceOrTw, String deli)
  9. getToDay(boolean withTime)