• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Month name and remain dates  RSS feed

 
Greenhorn
Posts: 23
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get month name and remain number of dates when i have number of dates from january first.
ex: number of dates= 33
so then month = February
remain dates =2
and also when i give the year, check whether it is leap year or not.
So, my question is how i can do these things in java?
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Java 8 or an earlier version? (The way dates work has changed significantly)

In either one, you'd have three steps:
1) Create a date representing January 1st.
2) Call am method to add X days to it.
3) Get the month (part one of your answer) and the day of the month (part two of your answer)
 
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you doing a Julian day to Gregorian day conversion? Because the Julian day concept is the number of days from Jan 1 of that year to current day.

From my understanding, you should able to do such conversion or simply work with such dates using the Joda Time API more easily than the Java API (eg Calendar). Not sure about Java 8

Also for leap year, you will have to write your own.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!