|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Getting Day_Of_Week from Calendar Class |
« View previous topic :: View next topic » |
Author |
Message
|
72dolfan |
Posted: Thu Mar 15, 2007 10:23 am Post subject: Getting Day_Of_Week from Calendar Class |
|
|
Acolyte
Joined: 02 May 2006 Posts: 53
|
Hi All,
I'm looking at the CALENDAR Class and trying to figure out how to get the day of the week that a certain date falls on, but I don't see the method that handles this. I've looked at the DATE Class which uses the getDay method which receives the year, month, and day). However, we have been instructed to use the CALENDAR Class.
Do any of you know which method in the Calendar Class returns only the number value for the day of the week?
Thanks!!!!!
Bill |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Thu Mar 15, 2007 10:31 am Post subject: Re: Getting Day_Of_Week from Calendar Class |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
72dolfan wrote: |
Hi All,
I'm looking at the CALENDAR Class and trying to figure out how to get the day of the week that a certain date falls on, but I don't see the method that handles this. I've looked at the DATE Class which uses the getDay method which receives the year, month, and day). However, we have been instructed to use the CALENDAR Class.
Do any of you know which method in the Calendar Class returns only the number value for the day of the week?
Thanks!!!!!
Bill |
This code should work.
Code: |
Calendar rightNow = Calendar.getInstance();
int dayofweek= rightNow.get(Calendar.DAY_OF_WEEK );
|
_________________ Marcin |
|
Back to top |
|
 |
72dolfan |
Posted: Thu Mar 15, 2007 10:38 am Post subject: Re: Getting Day_Of_Week from Calendar Class |
|
|
Acolyte
Joined: 02 May 2006 Posts: 53
|
marcin.kasinski wrote: |
72dolfan wrote: |
Hi All,
I'm looking at the CALENDAR Class and trying to figure out how to get the day of the week that a certain date falls on, but I don't see the method that handles this. I've looked at the DATE Class which uses the getDay method which receives the year, month, and day). However, we have been instructed to use the CALENDAR Class.
Do any of you know which method in the Calendar Class returns only the number value for the day of the week?
Thanks!!!!!
Bill |
This code should work.
Code: |
Calendar rightNow = Calendar.getInstance();
int dayofweek= rightNow.get(Calendar.DAY_OF_WEEK );
|
|
I thought about that, but what if I wanted to supply a specific date (year, month, & day) in time and get back the day of the week instead of the current date, which is what I believe the code you specified does?
Thanks,
Bill |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Thu Mar 15, 2007 10:41 am Post subject: Re: Getting Day_Of_Week from Calendar Class |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
72dolfan wrote: |
I thought about that, but what if I wanted to supply a specific date (year, month, & day) in time and get back the day of the week instead of the current date, which is what I believe the code you specified does?
Thanks,
Bill |
Have you tried set method of Calendar class ? _________________ Marcin |
|
Back to top |
|
 |
72dolfan |
Posted: Thu Mar 15, 2007 10:48 am Post subject: Re: Getting Day_Of_Week from Calendar Class |
|
|
Acolyte
Joined: 02 May 2006 Posts: 53
|
marcin.kasinski wrote: |
72dolfan wrote: |
I thought about that, but what if I wanted to supply a specific date (year, month, & day) in time and get back the day of the week instead of the current date, which is what I believe the code you specified does?
Thanks,
Bill |
Have you tried set method of Calendar class ? |
So if I issue the following;
set (int year, int month, int date)
and then run the code you supplied, that woudl do the trick?
Also, if I didn't want any time values (just looking for the day of the week for whatever date I specify) would I issue the clear method before the set and get?
Thanks,
Bill |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Thu Mar 15, 2007 10:54 am Post subject: Re: Getting Day_Of_Week from Calendar Class |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
72dolfan wrote: |
So if I issue the following;
set (int year, int month, int date)
and then run the code you supplied, that woudl do the trick?
Also, if I didn't want any time values (just looking for the day of the week for whatever date I specify) would I issue the clear method before the set and get?
Thanks,
Bill |
You can set everything
set(int year, int month, int date, int hour, int minute, int second)
You can use clear.
Pleas read this http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html _________________ Marcin |
|
Back to top |
|
 |
72dolfan |
Posted: Thu Mar 15, 2007 10:59 am Post subject: Re: Getting Day_Of_Week from Calendar Class |
|
|
Acolyte
Joined: 02 May 2006 Posts: 53
|
marcin.kasinski wrote: |
72dolfan wrote: |
So if I issue the following;
set (int year, int month, int date)
and then run the code you supplied, that woudl do the trick?
Also, if I didn't want any time values (just looking for the day of the week for whatever date I specify) would I issue the clear method before the set and get?
Thanks,
Bill |
You can set everything
set(int year, int month, int date, int hour, int minute, int second)
You can use clear.
Pleas read this http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html |
The link you provided is where I was looking and getting my info.
I think its pretty clear now.
Thanks for all your help!!!!!!!! |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|