Results 1 to 5 of 5
- 09-17-2010, 10:15 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 12
- Rep Power
- 0
Gregorian calendar multiple dates
Is it possible to create a GregorianCalendar object and set multiple dates in it? For creating intervals of time in it, and then associate it with a person.
This is to be used to create a vacation calendar so multiple intervals.
If you have any good idea or other approach to the problem, please share!:o
- 09-17-2010, 11:39 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 09-17-2010, 02:46 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 12
- Rep Power
- 0
Ok, I wrote some code, but I'm having trouble with calculating work days between 2 days.
This is it:
But GregorianCalendar.SATURDAY is of type int... How can I compare date to a GregorianCalendar object to see if it a saturday?Java Code:public static int daysBetween(GregorianCalendar startDate, GregorianCalendar endDate) { GregorianCalendar date = (GregorianCalendar) startDate.clone(); int daysBetween = 0; while (date.before(endDate)) { date.add(GregorianCalendar.DAY_OF_MONTH, 1); if(date.equals(GregorianCalendar.SATURDAY) || date.equals(GregorianCalendar.SUNDAY)){} else daysBetween++; } return daysBetween; }Last edited by tirwit; 09-17-2010 at 02:48 PM.
- 09-17-2010, 02:57 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
date.get(Calendar.DAY_OF_WEEK)? It's all in the API documentation you know ...
kind regards,
Jos
- 09-17-2010, 03:10 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 12
- Rep Power
- 0
I tried that before but it was not working. I had imported only the GregorianCalendar, because I thought that since GregorianCalendar is a extension of Calendar, all the methods would be there as well. Turns out I was wrong. I imported the Calendar and now it's working! Thank you so much.
PS: I was not slacking, I read the the API, but I have 3 days of Java, so I'm still learning to move around here (the "extend" stuff and such) :-) Thanks for your time showing me how to!
Similar Threads
-
Gregorian Calendar
By bindhuuk4 in forum New To JavaReplies: 1Last Post: 08-07-2009, 12:00 PM -
Creating a Gregorian Calendar using a Date object gives date - 1
By prachi_goliwadekar in forum New To JavaReplies: 1Last Post: 05-08-2008, 08:32 PM -
Help with gregorian calendar
By osval in forum New To JavaReplies: 2Last Post: 08-06-2007, 11:21 PM -
Calendar with multiple languages
By Marcus in forum Web FrameworksReplies: 1Last Post: 06-27-2007, 04:14 PM -
Gregorian calendar issue
By orchid in forum New To JavaReplies: 1Last Post: 05-16-2007, 06:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks