This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes java calander class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "java calander class" Watch "java calander class" New topic
Author

java calander class

Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
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?
shilpa kulkarni
Ranch Hand

Joined: Jun 07, 2000
Posts: 87
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));
Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
thanks.. ill check it out
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
This post will probably be more appropriate in the Java in general intermidiate forum. I will move it there.
Matthew Phillips

Matthew Phillips
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java calander class
 
Similar Threads
Retrive Month and Year
Is it possible to generate a random date with gregorian calendar?
Expiry date + format
java calander class
Custom Date class and Appointment class