Java Time Now getNow()

Here you can find the source of getNow()

Description

get Now

License

Open Source License

Declaration

public static String getNow() 

Method Source Code


//package com.java2s;

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

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

    public static String getNow() {
        return formatDateTime(new Date());
    }/*from ww w . j  av  a  2s  . c  o  m*/

    public static String getNow(String pattern) {
        return formatDateTime(new 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. getNow()
  2. getNow()
  3. getNow()
  4. getNow()
  5. getNow()
  6. getNow()
  7. getNow()
  8. getNow()
  9. getNow(boolean ifdatetime)