A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/java-tutorial/util/date/java_date_settime.php below:

Website Navigation


Java Date setTime() Method - w3resource

Java Date.setTime()MethodLast update on August 19 2022 21:50:42 (UTC/GMT +8 hours) public void setTime(long time)

The setTime() method is used to set Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

Package: java.util

Java Platform: Java SE 8

Syntax:

setTime(long time)

Parameters:

Name Description time The number of milliseconds.

Return Value:
a hash code value for this object.

Return Value Type: int

Pictorial Presentation of Jave Date setTime() method:

Example: Java Date.setTime() Method

import java.util.Date;

public class Main {
   public static void main(String[] args) {

      // create a date
      Date date = new Date(2012, 2, 2);

      // set the date for 100000 milliseconds after January 1, 1970 00:00:00 gmt.
      date.setTime(1000000000);

      // print the date
      System.out.println("New date: " + date.toString());
   }
}
 

Output:

New date: Mon Jan 12 13:46:40 UTC 1970

Java Code Editor:

Previous:hashCode Method
Next:toInstant Method




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4