
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MonthDay from() method in Java
An instance of a MonthDay object can be obtained from a Temporal object using the from() method in the MonthDay class in Java. This method requires a single parameter i.e. the Temporal object and it returns the MonthDay object that is obtained from the Temporal object.
A program that demonstrates this is given as follows
Example
import java.time.*; public class Main { public static void main(String[] args) { MonthDay md = MonthDay.from(ZonedDateTime.now()); System.out.println("The MonthDay is: " + md); } }
Output
The MonthDay is: --02-22
Now let us understand the above program.
The instance of the MonthDay object is obtained from the Temporal object using the from() method and then it is displayed. A code snippet that demonstrates this is as follows:
MonthDay md = MonthDay.from(ZonedDateTime.now()); System.out.println("The MonthDay is: " + md);
Advertisements