Results 1 to 3 of 3
Thread: .DAY_OF_WEEK always returns 7
- 08-20-2010, 02:18 PM #1
Member
- Join Date
- Aug 2010
- Location
- England
- Posts
- 12
- Rep Power
- 0
.DAY_OF_WEEK always returns 7
Hi there, I'm setting a calendar to a date that's pulled from an array of results of a MySQL query stored in events[y][1].
The problem is this: If I add in System.out.println(eventdatecal); I can see that the DAY_OF_WEEK variable changes depending what date I get from events[y][1] and it's correct. But as soon a I try and pass it into xindex and System.out.println(xindex); it returns 7, every time. Am I doing something really silly or am I right in thinking this makes no sense?Java Code:GregorianCalendar eventdatecal = new GregorianCalendar(TimeZone.getTimeZone("Europe/London"),Locale.UK); Date eventdatesimple = simpledateform.parse(events[y][1]); eventdatecal.setTime(eventdatesimple); System.out.println(eventdatecal); /*This returns 0->6, Sun->Sat for .DAY_OF_WEEK*/ int xindex = eventdatecal.DAY_OF_WEEK; System.out.println(xindex);/*But this always returns 7 :@*/Last edited by shurgs; 08-20-2010 at 02:20 PM. Reason: typo
- 08-20-2010, 02:27 PM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Hi,
What you currently did is assigning the value of a constant field Calendar.DAY_OF_WEEK to the xindex variable. Calendar.DAY_OF_WEEK is an integer field that have a value 7. So you'll always get 7 printed out as the output.
From your requirement your code should be:
Java Code:int xindex = eventdatecal.get(Calendar.DAY_OF_WEEK);
Last edited by wsaryada; 08-20-2010 at 02:31 PM.
Website: Learn Java by Examples
- 08-20-2010, 02:32 PM #3
Member
- Join Date
- Aug 2010
- Location
- England
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
IndexSearch.docfreq returns 0.0
By noir in forum LuceneReplies: 0Last Post: 04-26-2010, 09:32 AM -
Carriage Returns in JTEXTAREA
By AJArmstron@aol.com in forum Advanced JavaReplies: 8Last Post: 04-17-2010, 07:34 PM -
String file and carriage returns
By AJArmstron@aol.com in forum New To JavaReplies: 2Last Post: 04-17-2010, 01:28 AM -
NetworkInterface returns only ports that are up
By dogbert in forum NetworkingReplies: 0Last Post: 10-13-2009, 05:12 PM -
What's the need for co-variant returns ?
By ajeeb in forum New To JavaReplies: 0Last Post: 03-23-2009, 09:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks