Java > Date Time
GetTheCurrentTime
GetTheCurrentTime package com.ack.j2se.date; import java.util.Calendar; import java.util.Date; public class GetTheCurrentTime { public static void main( String[] args ) { // one way long currentTimeInMillis = System.currentTimeMillis(); Date today = new Date( currentTimeInMillis ); System.out.println( today ); // another way Calendar cal = Calendar.getInstance(); today = cal.getTime(); System.out.println( today ); } }
Java Codes
Beginners
Core Java
Date Time
Java2D
Java Applets
Java AWT
Mathematics
Networking
Servlets
Session
Sound
Swing
Threads
Util Package
JDBC
Learning
Other
Security
XML