Java Date getTime() Method22 Mar 2025 | 1 min read The getTime() method of Java Date class returns the number of milliseconds since January 1, 1970, 00:00:00 GTM which is represented by Date object. Syntax:ParametersNA ReturnIt returns the number of milliseconds since January 1, 1970, 00:00:00 GTM. ExampleOutput: Number of milliseconds science January 1, 1970, 00:00:00 GTM : 60818841000000 Next Topicjava.util.Date |
Java Date Method The method of Java Date class returns a copy/clone of this object. This method overrides clone in class Object. Syntax: public object Parameters NA Return It returns a clone/copy of this instance. Example 1 import java.util.Date; public class JavaDateCloneExample1 { public static void main(String[] args) { Date d=new Date(2018,9,21); System.out.println("Clone of your...
1 min read
Java Date Method The method of Java Date class returns the value between 0 to 11 which represents the month of the year. This method is deprecated as of JDK version 1.1 and replaced by Calender.get(Calender.MONTH) Value Month 0 January 1 February 2 March 3 April 4 May 5 June 6 July 7 August 8 September 9 October 10 November 11 December Syntax: @Deprecated public int Parameters NA Return It returns the month of the year...
1 min read
Java Date Method The from(Instant instant) method of Java Date class returns an instance of date which is obtained from an Instant object. Syntax: public static Date from(Instant instant) Parameters instant - It is the instant to convert Return It returns a date representing the same point on the timeline as...
1 min read
Java Date Method The method of Java Date class converts this date object into a String in form "dow mon dd hh:mm:ss zzz yyy". This method overrides toString in class object. Syntax: public String Parameters NA Return It returns a String representing this date object. Example 1 import java.util.Date; public class JavaDateToStringExample1...
1 min read
Java Date Method The method of Java Date class returns a Boolean value on the basis of compression between two dates for equality. This method overrides equals in class Object Syntax: public boolean equals(Object obj) Parameters obj - an object to be compared Return It returns true if the objects...
1 min read
Java Date Method The method of Java Date class sets a date object. It sets date object to represent time milliseconds after January 1, 1970 00:00:00 GMT. Syntax: public long setTime(long time) Parameters time: the number of milliseconds Example 1 import java.util.Date; public class JavaDateSetTimeExample1 { public static void main(String[] args) { Date...
1 min read
Java Date Method The method of Java Date class compares two dates and sort them for order. This method is specified by compareTo in interface Comparable<Date>. Syntax: public int compareTo(Date anotherDate) Parameters anotherDate - a date to be compared Return It returns the value 0 if the argument Date is...
1 min read
Java Date Method The method of Java Date class sets hour of the day of this date object to represent new value of date object. It changes the ious hour of the day value to the new specified value. This method is deprecated as of...
1 min read
Java Date Method The method of Java Date class tests whether the date is before the specified date or not. Syntax: public boolean before(Date when) Parameters when - a date Return It returns a Boolean value. It will return true if this date is before the specified date otherwise false. Exception NullPointerException...
1 min read
Java Date Method The method of Java Date class returns a value which is a hash code for this object. This method overrides hashCode in class Object. Syntax: public int Parameters NA Return It returns a hashCode value for this object. Example 1 import java.util.Date; public class JavaDateHashCodeExample1 { public static void main(String[]...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India