100% found this document useful (3 votes)
12K views1 page

GET DATE & TIME in Java

GET DATE and TIME IN ANY FORMAT import java.util.calendar; import java.text.SimpleDateFormat; public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; public static String now(); return sdf.format(cal.getTime());.

Uploaded by

palitha4u
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
12K views1 page

GET DATE & TIME in Java

GET DATE and TIME IN ANY FORMAT import java.util.calendar; import java.text.SimpleDateFormat; public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; public static String now(); return sdf.format(cal.getTime());.

Uploaded by

palitha4u
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// GET DATE & TIME IN ANY FORMAT

import [Link];
import [Link];

public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";

public static String now() {


Calendar cal = [Link]();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return [Link]([Link]());

You might also like