Forums Register Login

java calander class

+Pie Number of slices to send: Send
I am using the Java Calender class and I am reading in a Year for a Day of Year, for example 2001 for the year, and 045 for the Day of Year. Does anyone know how I would could get this Day of Year to set the month as Feburary. Is there anything in the Calander class which can read the Day of Year and automatically tell what month it is? If there is how would I do this?
+Pie Number of slices to send: Send
This piece of code returns date as 14 Feb 2001.
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2001);
cal.set(Calendar.DAY_OF_YEAR, 45);
System.out.println(cal.get(Calendar.DATE));
System.out.println(cal.get(Calendar.MONTH)+1);
System.out.println(cal.get(Calendar.YEAR));
+Pie Number of slices to send: Send
thanks.. ill check it out
+Pie Number of slices to send: Send
This post will probably be more appropriate in the Java in general intermidiate forum. I will move it there.
Matthew Phillips
Did you miss me? Did you miss this 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 1076 times.
Similar Threads
Is it possible to generate a random date with gregorian calendar?
Custom Date class and Appointment class
Retrive Month and Year
Expiry date + format
java calander class
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:52:02.