Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8755599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:53:17+00:00 2026-06-13T13:53:17+00:00

Why does Java make it not obvious how to get the day of the

  • 0

Why does Java make it not obvious how to get the day of the month from a Date object?

.getDay() was deprecated, it is recommended to use Calendar.get(Calendar.MONTH)

This makes little sense to me and I was curious what the rationale behind this deprecation is.

I have a Date object and I just want the day. It’s the most natural thing ever and I can’t invoke it. This design is wrong and therefore my code is not working the way it should:

private String getIngivningsDag() {

    return ""+ingivningsDatum.getDate();
}



private String getIngivningsMonth() {

    return ""+ingivningsDatum.getmonth();
}

private String getIngivningsYear() {

    return ""+ingivningsDatum.getYear();
}

Update

here’s the “solution”:

public String getIngivningsDag() {

    Calendar cal = Calendar.getInstance();
    cal.setTime(ingivningsDatum);
    return cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)+"";
}

Here’s how it should look simple and good without the design errors of Java and using method parameters instead of strange Class methods and factories:

public String getIngivningsDag() {

    return ingivningsDatum.getDay(Calendar.GREGORIAN, "SE");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:53:18+00:00Added an answer on June 13, 2026 at 1:53 pm

    Not only that method, most of the methods of Date class and some constructors are now deprecated. You have to use Calendar class to get DAY, or MONTH from your Date object.

    However, I would suggest you to try out Joda-Time API, that will make you much more happier, because, even Calendar class is a bit inconsistent when it comes to indexing of MONTH, which starts from 0 in it.

    But, still, as for your current problem, you can convert your Date object to a Calendar instance using: –

    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    
    System.out.println(cal.get(Calendar.MONTH));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java EE web application that does not make use of EJBs.
I'm getting this warning from the compiler which does not make sense at all
When java calls the get method from hashmap does java perform a equals() comparison?
Does something like this make any sense at all in Java? class A<T extends
Does Java guarantee array initialization? Let's say I use the code char[] uuid =
Does java has library exception class which means actually not an error, but good
Java does not have the concept of pointers . So how does java implement
public or protected methods does not make any difference for a private nested class
Since java does not support multiple inheritance I have a problem getting this to
I am sorry if my question does not make any sense. So here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.