Java: Display information of a default calendar
2. Get Calendar Date Info
Write a Java program to get and display information (year, month, day, hour, minute) about a default calendar.
Sample Solution:
Java Code:
Sample Output:
Year: 2017 Month: 5 Day: 20 Hour: 1 Minute: 57
N.B.: The result may varry for your system date and time.
Pictorial Presentation:
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to extract and display year, month, day, hour, minute, and second from the default Calendar.
- Write a Java program to retrieve complete calendar field values including week of year and day of week.
- Write a Java program to format and display calendar details from a default Calendar instance into a readable string.
- Write a Java program to compare field values from two Calendar instances and display any differences.
Go to:
PREV : Create Date Using Calendar.
NEXT : Get Calendar Max Values.
Java Code Editor:
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.