We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I couldn't figure out how to solve the problem using the Calender class.
So I used LocalDateTime and DateTimeFormatter classes instead.
This approach appears clearer to me also.
Note :- You would also need to import java.time.LocalDateTime and java.time.format.DateTimeFormatter on the toplevel of the file.
This is the code of the method -
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
I couldn't figure out how to solve the problem using the
Calender
class.So I used
LocalDateTime
andDateTimeFormatter
classes instead. This approach appears clearer to me also. Note :- You would also need to importjava.time.LocalDateTime
andjava.time.format.DateTimeFormatter
on the toplevel of the file. This is the code of the method -