Get,Current,Time,java

sun 9/19/2016 0

Get The Current Time in java

Java
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 );
  }
}
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments