Java-Get Date Properties

Get Date Properties

Date defines many methods that obtain the standard properties of a Date object. For example, getYear( ) method returns the year represented by this date since 1900, getMonth( ) method returns the month represented by this date, getDate( ) method returns the day of the month represented by this date, getHour( ) method returns the hour represented by this date, getMinutes( ) method the number of minutes past the hour represented by this date, and getSeconds( ) method returns the number of seconds past the minute represented by this date.

Program

0

Program Source

import java.util.Date;

public class Javaapp {

    public static void main(String[] args) {
        
        Date dat = new Date();
        System.out.println("getYear From 1900 : "+dat.getYear());
        System.out.println("getMonth     : "+dat.getMonth());
        System.out.println("getDate      : "+dat.getDate());
        System.out.println("getHours()   : "+dat.getHours());
        System.out.println("getMinutes   : "+dat.getMinutes());
        System.out.println("getSeconds() : "+dat.getSeconds());
    }
}

Leave a Comment