Create java Date from long by specifying time unit in Java

Description

The following code shows how to create java Date from long by specifying time unit.

Example


/*from  w  w  w  . j  a  v  a 2 s.  c  o  m*/
import java.util.Date;

public class Main {
  public static void main(String[] args) {
    Date d = new Date(365L * 24L * 60L * 60L * 1000L);
    System.out.println(d);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone