Java Now now()

Here you can find the source of now()

Description

Get today date and current time in format: yyyyMMdd_HHmm.

License

Open Source License

Return

current date and time in format yyyyMMdd_HHmm

Declaration

public static String now() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    private static final String FORMAT = "yyyyMMdd_HHmm";

    /**//from  w w  w.ja  v a2s . c o  m
     * Get today date and current time in format: yyyyMMdd_HHmm.
     *
     *
     * @return current date and time in format yyyyMMdd_HHmm
     */
    public static String now() {

        final Calendar calendar = Calendar.getInstance();
        final SimpleDateFormat formatter = new SimpleDateFormat(FORMAT);

        return formatter.format(calendar.getTime());
    }
}

Related

  1. now()
  2. now()
  3. now()
  4. now()
  5. now()
  6. now()
  7. now()
  8. now()
  9. now()