Java Now formatNow(String fmt)

Here you can find the source of formatNow(String fmt)

Description

format Now

License

Apache License

Declaration

public static String formatNow(String fmt) 

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 formatNow(String fmt) {
        return formatDate(new Date(), fmt);
    }//w w w . j ava  2 s  .  c  om

    public static String formatDate(Object date, String fmt) {
        if (date == null) {
            return null;
        }
        if (!(date instanceof Date)) {
            return date.toString();
        }
        SimpleDateFormat sdf = new SimpleDateFormat(fmt);
        return sdf.format(date);
    }
}

Related

  1. compareDateWithNow(Date date1)
  2. compareWithNow_2(String t)
  3. formatNow()
  4. formatNow()
  5. formatNow()
  6. formatNow(String pattern)
  7. formatNow(String style)
  8. formatTime(Date now, String pattern)
  9. getAllnowTime()