FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 4216   



Using java.util.Calendar Class in Java, you can get current Year, Month, Date, Hour, Minute & Second in Java.

import java.util.Calendar;

public class GetTimeDetails {
    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();

        System.out.println("Year: " + calendar.get(Calendar.YEAR));
        System.out.println("Month: " + calendar.get(Calendar.MONTH));
        System.out.println("Date: " + calendar.get(Calendar.DATE));

        System.out.println("Hour: " + calendar.get(Calendar.HOUR));
        System.out.println("Minute: " + calendar.get(Calendar.MINUTE));
        System.out.println("Second: " + calendar.get(Calendar.SECOND));
    }
}

Output

Year: 2017
Month: 8
Date: 7
Hour: 7
Minute: 45
Second: 54



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News