Java Now formatNow()

Here you can find the source of formatNow()

Description

Formats a Date into a date/time string.

License

Apache License

Return

the formatted time string.

Declaration

public static String formatNow() 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**/*from ww w.j  a va 2 s  . co  m*/
     * Formats a Date into a date/time string.
     * now the time value to be formatted into a time string.
     * @return the formatted time string.
     */
    public static String formatNow() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HH:mm:ss");
        return format.format(new Date());
    }
}

Related

  1. calNow()
  2. compareDateWithNow(Date date1)
  3. compareWithNow_2(String t)
  4. formatNow()
  5. formatNow()
  6. formatNow(String fmt)
  7. formatNow(String pattern)