How to get current date, month, year and day of week in Java program - Example tutorial

Here is a quick Java tip to get the current date, month, year, and day of the week from the Java program. Java provides a rich Date and Time API though having thread-safety issue but it's rich in function and if used locally can give you all the date and time information that you need for your enterprise Java application. In the last Java tutorial on Date and Time API we have seen how to get the current date and time from different timezone using DateFormat and SimpleDateFormat classes and in this post, we will get some more details like the current month, year, day of the week, etc by using java.util.Calendar class.  Just keep in mind that the Calendar instance should not be shared between multiple threads.

تعليقات

المشاركات الشائعة من هذه المدونة

Why use Underscore in Numbers from Java? Underscore in Numeric Literals Example

3 ways to convert String to Boolean in Java? Examples

Coursera's TensorFlow: Advanced Techniques Specialization Review [2022]