Home » Category » Java Programming

Java Programming: Add Date and Time Class

200| Wed, 30 Apr 2008 21:46:00 GMT| janwillem_borleffs| Comments (0)
I want to add Date and Time to my Java Program , How can i get the system time and date and pass to Java program ?

import java.text.SimpleDateFormat;
import java.util.Date;
...
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new Date()));

*Or* when you are only interested in the system date and time in ms: long sysTimeMs = System.currentTimeMillis();

JW

Keywords & Tags: add, date, time, class, java, programming

URL: http://java.itags.org/java-programming/332359/
 
«« Prev - Next »» 0 helpful answers below.

Java Programming Hot Answers

Java Programming New questions

Java Programming Related Categories