Forums Register Login

Get Month name and remain dates

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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)
+Pie Number of slices to send: Send
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.
pie. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 449 times.
Similar Threads
date dateformat
Is it a bug in jdk1.3?
SQL Show Previous Month Date Question
Wrongly Date is updated
Date?????
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:25:41.