GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java Date Class
Selected Reading
Java Date ClassIntroductionThe Java Util Date class represents a specific instant in time, with millisecond precision. Class declarationFollowing is the declaration for java.util.Date class − public class Date extends Object implements Serializable, Cloneable, Comparable<Date> Class constructors
Class methods
Methods inheritedThis class inherits methods from the following classes −
Creating a Date instance of current date ExampleThis Java example demonstrates the from() method of Date class to get Date instance of current time. package com.tutorialspoint;
import java.time.Instant;
// Import the Date package
import java.util.Date;
// Main public class
public class DateDemo {
public static void main(String[] args) {
// create a date of current time
Date date = Date.from(Instant.now());
// print the date instance
System.out.println("Date: " + date.toString());
}
}
OutputLet us compile and run the above program, this will produce the following result − Date: Mon Apr 01 10:20:08 IST 2024 Advertisements
| ||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |