How to Get Day from Date in Java

In this post, we will see how to get day from date in java.

There are multiple ways to get day from date in java. Let’s go through them.

Using java.util.Date

You can use Calendar class to get day of week in number and SimpleDateFormat if you need it in text format like Tuesday.

Let’s see with the help of example:

Output:

Day of week in number:3
Day of week in text:Tuesday

Here day of week in number ranges from 1(Calendar.SUNDAY) to 7(Calendar.SATURAY). Since date of week is tuesday, that’s why we got output as 3

Using java.time.LocalDate

You can use getDayOfWeek() method of LocalDate class to get day name of week from date in java. It will work for Java 8 or later.

Let’s see with the help of example:

Output:

Day of week in number:2
Day of week in text:TUESDAY

Here day of week in number ranges from 1(Monday) to 7(Sunday) as it has its own enum. Since date of week is TUESDAY, that’s why we got output as 2
That’s all about How to day from date in java.

Was this post helpful?

Related Posts

  • 26 November

    Check if Date Is Between Two Dates in Java

    Table of ContentsIntroductionDate & Local Date Class in JavaCheck if The Date Is Between Two Dates in JavaUsing the isAfter() and isBefore() Methods of the Local Date Class in JavaUsing the compareTo() Method of the Local Date Class in JavaUsing the after() and before() Methods of the Date Class in JavaUsing the compare To() Method […]

  • 05 October

    Find Difference Between Two Instant in Java

    Table of ContentsWays to find difference between two Instant in JavaUsing Instant’s until() methodUsing ChronoUnit EnumUsing Duration’s between() method In this post, we will see how to find difference between two Instant in Java. Ways to find difference between two Instant in Java There are multiple ways to find difference between two Instant in various […]

  • 05 October

    Find Difference Between Two LocalDate in Java

    Table of ContentsWays to find difference between two LocalDate in JavaUsing LocalDate’s until() methodUsing ChronoUnit EnumUsing Duration’s between() methodUsing Period’s between() methodFrequently asked questionsHow to find difference between two LocalDate in Java in Days?How to find difference between two LocalDate in Java in Years?How to find difference between two LocalDate in Java in Months?How to […]

  • 26 September

    Get List of Weekday Names in Java

    Table of ContentsUsing DateFormatSymbols’s getWeekdays() methodUsing DateFormatSymbols’s getShortWeekdays() method [For short names]Using DateFormatSymbols’s getWeekdays() with Locale In this post, we will see how to get list of weekday names in Java. Using DateFormatSymbols’s getWeekdays() method We can use DateFormatSymbols's getWeekdays() to get list of weekday names in Java. It will provide complete weekday names like […]

  • 24 September

    Get List of Month Names in Java

    Table of ContentsUsing DateFormatSymbols’s getMonth() methodUsing DateFormatSymbols’s getShortMonths() method [ For short names]Using DateFormatSymbols’s getMonth() with Locale In this post, we will see how to get list of months name in Java. Using DateFormatSymbols’s getMonth() method We can use DateFormatSymbols's getMonth() to get list of months in Java. It will provide complete month names like […]

  • 20 September

    Get Unix Timestamp in Java

    Table of ContentsWays to get unix timestamp in JavaUsing Instant classUsing System.currentTimeMillis()Using Date’s getTime() methodConvert Date to unix timestamp in JavaUsing Instant classUsing Date’s getTime() method In this post, we will get unix timestamp in Java. As per wikipedia Unix time is a system for describing a point in time. It is the number of […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.