Calendar doesn't know what day it is

I'm making a program that will take a date and depending what button you click will add a number of days onto that date. It also compensates for weekends and any public holidays you specify. It takes the date from the clipboard in a dd/mm/yyyy hh:mm:ss format and converts that into a calendar. The calendar is then added to and the result is pasted to the clipboard.
Anyway, the problem is, today (04/04/2008) is Friday, it thinks it's Monday. Wtf?
I tried indulging its eccentricities by just pretending that it is Friday and telling it that weekends are Wednesdays and Thursdays. But now, it's shifted again, and all the days are one day different from its previous dillusion. What the hell is with this calendar? How can it not know what day it is? If the calendar says it's Friday, how do we know that it's not? What is a Friday? What are we? How did this break down into an existential crisis so quickly?
String s = clipboard.getClipboardContents();     
StringTokenizer tok = new StringTokenizer(s, "/ :");
try{
     int day = Integer.parseInt(tok.nextToken());
     int month = Integer.parseInt(tok.nextToken());
     int year = Integer.parseInt(tok.nextToken());
     int hour = Integer.parseInt(tok.nextToken());
     int minute = Integer.parseInt(tok.nextToken());
     int seconds = Integer.parseInt(tok.nextToken());
     c = new GregorianCalendar(year, month, day, hour, minute, seconds);
catch(Exception e){etc...
and then later on it adds the days using
c.add(Calendar.DAY_OF_WEEK);
and then displayed with
System.out.println(dayToString(day) + " " + c.get(Calendar.DAY_OF_MONTH) + "/" + c.get(Calendar.MONTH) + "/" + c.get(Calendar.YEAR));
Edited by: RedUnderTheBed on Apr 3, 2008 5:36 PM

One of your problems is with how you try to parse the date string. The manual way that you are doing it will take the month number (4) and assign the date the month of May, since calendar uses a 0 base for months (0 represents January). I think that May 4th, 2008 is in fact a Monday. I recommend that instead of parsing the date like so, that you use the SimpleDateFormat class instead. It's pretty easy to use once you play around with it.

Similar Messages

  • ICalendar: How do I know what day, in month view, I am working on?

    The calendar in Mavericks is so frustrating compared to SL. How do I know what day, in month view, I am working on? There is no highlight or box or anything. Am I missing something? Also I suppose its not possible to just see 1 month anymore like it use to be instead of seeing 6 weeks. Thanks.  Sure wish Apple would let us keep our Macs the way WE like it with a classic setting everytime they add something that they think is better. Like those awesome grey icons all over the place instead of color.

    The day with the red line on top is today

  • My brother and I have iPhone 4S  with operating system or seven I recently sent him a video gift from the iTunes store he received his email but doesn't know what to do next please help

    I gave my brother a gift from iTunes music video he received the email but doesn't know what to do to access it

    Hi
    I am sorry to see you are having problems
    I suggest you contact the forum mods they should be able to get this problem sorted for you this is a link to them http://bt.custhelp.com/app/contact_email/c/4951
    They normally reply by email or phone directly to you within 3/5 working days they will take personal ownership of your problem until resolved and will keep you informed of progress
    They are a UK based BT specialist team who have a good record at getting problems solved
    This is a customer to customer self help forum the only BT presence here are the forum moderators
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • I downloaded an update for my Safari web browser to "snow leopard". When I click on the .dmg file, a window opens up with a .pkg file but when I click on the .pkg file I get a prompt saying that it doesn't know what program to open it with. with a

    I downloaded an update for my Safari web browser to "snow leopard". When I click on the .dmg file, a window opens up with a .pkg file but when I click on the .pkg file I get a prompt saying that it doesn't know what program to open it with.

    I suspect if you're trying to open a file in 08 that's been opened in 09 the file has been updated to 09 and will not open in 08.

  • I preordered the iPod Touch 5th Generation, and it says it will be here in October. Does anybody know what day in October, or have any idea when in October?

    I preordered the iPod Touch 5th Generation, and it says it will be here in October. Does anybody know what day in October, or have any idea when in October?

    Apple has not provided additional details, sorry.

  • Right hand doesn't know what the left hand is doing.  ARG!

    Yesterday... I lost 4G LTE access on my phone.  So, I call Technical Support asking what's going on.  By the way, they didn't have a clue what was going on and why 4G was on the fritz, 3G was working through.  I was just about to go to the Verizon Store to have my phone looked at when I stumbled upon a notice on another Android forum that stated that the Verizon 4G network was again on the fritz.  The article is located at http://stopthecap.com/2011/12/07/verizon-wireless-lte-outage-impacts-service-on-east-coast/.
    Also here... http://www.dslreports.com/forum/r26627655-VZW-LTE-data-outage-in-NYC-metro-area
    OK, if this sounds like a rant, then you'd be right!  Because it is!
    How hard is it to put a message somewhere on the main company message boards, send an email, send a notice... something?  Anything!  To let everyone in the company know what is going on.  You are doing a great disservice to your customers in not telling your representatives both on the phone and in the stores that something is wrong with the network.  You are sending people scrambling for a fix for their phones when in reality the network is broken again.
    Seriously... the right hand doesn't know what the left hand is doing!

    I agree, a simple text sent or a post on here would be nice!

  • Firefox doesn't know what to do with iWeb blog pages.

    Why?
    Firefox doesn't know what to do with iWeb blog pages. All the entries are missing, and in their place are the words, Blog Summary Widget. Is this a problem with just my version of Firefox (like maybe I'm missing a plug-in or something?) or is this a failure on iWeb's part?
    http://web.me.com/gomerpyle/MonarchRenovations/Before_and_After/Before_andAfter.html

    There have been some quantum leaps in design and usefulness between FF1 and FF3. I'm not surprised that FF1 can't handle it. Download the latest FF for Mac and/or Windows here: http://www.mozilla.com/en-US/firefox/all.html

  • Sister was using my iPod, she changed Apple id to hers, then forgot the iTunes password, now it's disabled she doesn't know what backup email she use or the security questions HELP can Apple reset my iPod?

    sister was using my iPod, she changed Apple id to hers, then forgot the iTunes password, now it's disabled she doesn't know what backup email she use or the security questions HELP can Apple reset my iPod?

    Is there a way to find my Apple ID Name if I can't remember it?
    Yes. Visit My Apple ID and click Find your Apple ID. See Finding your Apple ID if you'd like more information.
    How do I change or recover a forgotten Apple ID Password?
    If you've forgotten your Apple ID Password or want to change it, go to My Apple ID and follow the instructions. SeeChanging your Apple ID password if you'd like more information.
    Forgotten Security Questions/Answers
    You need to contact Apple by:
    1 - Use the Express lane and start here:
    https://expresslane.apple.com
    then click More Products and Services>Apple ID>Other Apple ID Topics>Forgotten Apple ID security questions.
    or
    Apple - Support -form iTunes Store - Contact Us
    2 - Call Apple in your country by getting the number from here:
    http://support.apple.com/kb/HE57
    or          
    Apple ID: Contacting Apple for help with Apple ID account security
    3 - Use your rescue email address if you set one up
    Rescue email address and how to reset Apple ID security questions
    For general  information see:
    Apple ID: All about Apple ID security questions

  • I downloaded cs6 master collection but once it was downloaded my computer doesn't know what app to use to open and install??

    I downloaded cs6 master collection but once it was downloaded my computer doesn't know what app to use to open and install??

    I have windows 8 and I tried to download the cs6 master collection bot the files available on the adobe website
    is that what you were asking?
    I recently refreshed my computer and it wipedout any programs that I had installed so im trying to get them back

  • Even my iPod doesn't know what's wrong with it.

    I have a 4th Gen iPod that just stopped working a few months ago. I have checked the iPod support pages, but I have the apparently unique problem of getting pretty much every error message that you can get. The Sad iPod, the Folder and exclamation mark, the low battery symbol, and sometimes the Apple apple for a few seconds before it turns off.
    It doesn't seem like it's a battery issue, since it was working fine one day and then just stopped starting up the next. It might be, though, I simply don't know. I've been pretty much resigned to the probability that my iPod is broken forever, but I really miss it.
    Has anyone experienced anything similar to this and know what is wrong? I highly doubt that several problems just started over the course of one night, but I get all the error messages. My iPod isn't covered under warranty any more, so if there is some way to get it fixed, knowing the cost for fixing whatever is wrong would be helpful as well.
    Thanks.

    I'm assuming you tried to restore/update it.
    It sounds like either a nasty hardware issue or you could have corrupted files on your iPod.
    When all else fails, get a refurb from apple.
    Their cheaper and just as good.

  • 7205 doesn't know what an area code is?

    So the "habitat mode" is perky, but I'm having a problem getting the 7205 (aka "Intrigue") to simply recognize my contacts in any coherent way.
    Silliness #1: I'm in the 415 area code.  If I have a contact "Mary" with phone number "555-1111" in my contact list and Mary calls me, the phone displays the number as "415-552-1111" and doesn't assocate it with Mary.  Statisticly aren't most contact phone numbers local for most people?  Remarkable.
    Silliness #2: So I guess I have to put the area code in for all local contacts. Then if I have a contact "Joe" with phone number "415-555-2222" (including the area code this time) in my contact list and Joe calls me, the phone displays his name.  But if I call him by just dialing the local number, it doesn't realize it is equivalent and does no better than display the number in the call history!  Astounding.
    Sillines #3: I have a contact "Mom" with the phone number "(222) 555-3333" in my contact list (This is how your contacts will be loaded if you transfer them using bluetooth, for instance).  When Mom calls, it only displays the number, not the name.  Why?  Because it doesn't know that "(222)" is the same as "222-", and is in fact the most common way of denoting area codes in the US!  Incredible.
    God knows how it will butcher country codes.  I'm afraid to try.

    I'm having a similar problem with the 7705...
    when i call the contact from my contact list, it associates it with her name, but not if she calls me.
    if i type in the number without area code, it doesn't recognize her, and if i send a message with the icon it put up for her in habitat mode, she doesn't get it.
    if i try calling from that icon in habitat mode it pops up with a strange error message saying "originating addr same as cb or non-existant"
    it's the only contact having this problem so far... and I've tried deleting the contact and putting it in again, to no avail...
    not sure what I should do about, any luck fixing your problem?

  • HT1212 my daughter has locked her iphone by mistyping when setting her passcode so she doesn't know what the passcode is to unlock the phone.  HELP

    my daughter locked her iphone when trying to set a passcode and mis typed.  she doesn't know the passcode.  what can i do?

    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
    A
    1. iOS- Forgotten passcode or device disabled after entering wrong passcode
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. Restoring iPod touch after forgotten passcode
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. iOS- Understanding passcodes
    6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    7. iOS - Unable to update or restore
    Forgotten Restrictions Passcode Help
                iPad,iPod,iPod Touch Recovery Mode
    You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
    You can restore from a backup if you have one from BEFORE you set the restrictions passcode.
    Also, see iTunes- Restoring iOS software.

  • How do i know what day i activated my iphone?

    I need to figure out what day exactly i activated my iphone.  i know the month i just dont know how to figure out what day

    If you're trying to tie it to warranty period, that's not how Apple does it. It's tied to the date of sale, or date of shipment.

  • Irony: Bridge doesn't know what to do with .pictclipping file (Mac)

    Bridge 5.0.2.4 running under Mac OS X Lion 10.7.5 does not know to which application to hand a ".pictclipping" file.
    This type of file normally opens in the Finder, without launching any other application or utility of any kind.
    However, Bridge doesn't even show a preview in The Content panel or in the Preview panel either.  Double clicking on such a file within Bridge's Content panel results in Bridge launching and/or bringing to the front the TextEdit application showing a totally empty window showing the actual name of the file in its title bar but a completely blank window.
    Needless to say, it's not possible to establish a file association between this kind of file and the Finder from within Bridge.
    Just another example of the lack of attention and resources Adobe has shown toward its stepchild application, Bridge. 
    Adobe Photoshop 13.0.5 does not open such files through its Open menu item dialog either, even though it correctly detects them as a .PICT files.

    CameraAnn wrote:
    The only way to see an image contained within a PictClipping in OSX 10.8.4 is in Apple's own Finder App. and it appears that you can't do anything with it once you have "found" it?!  …
    That's exactly as it is meant to be, Ann.  An image that is lightning fast to create, lightning fast to view and utterly impossible to alter, manipulate or edit! 
      You can, however, copy its contents to your Clipboard after Command+A.
    CameraAnn wrote:
    Clicking on it, only opens it in an empty RTF window.
    Double clicking on it in all Mac OS versions I know, from Mac OS 9.x and earlier up to and including Lion 10.7.5, immediately shows the image in the Finder itself in a stretchable, floating, Finder window.
    Have no knowledge of Mountain Lion (which won't run on my Mac Pro1,1 Quad) but what you describe above is exactly what happens when you double click the image in Bridge's Content panel, and that's just plain wrong behavior.  The blank window is not a Finder window in that case, but a TextEdit window.
    CameraAnn wrote:
    Images from other than MS Office progams can be drag-copied to the Desktop as JPEGs and MS Office images can always be Copied/Saved As to the location and format of your choice.
    So I am not sure why anyone would need to make an Image PictClipping anyway?
    Oh, I make pictClippings and textClippings all the time, every single day!
    For example, I have a large collection of both pictClippings and textClippings containg killer tips by Photoshop luminaries like Bruce Fraser, Ann Shelbourne and Andrew Rodney, that I've created over the years—in a nanosecond each time—by simply highlighting portions of their Adobe forum posts and dragging the selection to the Desktop:  instant, permanent reminders!
    No application needed to open them or to copy their contents.
    Another helpful use is to select text from emails giving me the registration or serial number of applications or plug-ins I buy online then save the clipping in a Reg_SerialNumbers folder for later.
    CameraAnn wrote:
    However, Bridge will show only the file icon for any image-containing Clipping…
    Sure, but that's just the unacceptable, unnecessary tease I'm complaining about.  
    CameraAnn wrote:
     …Double-Clicking on one will immediately open a small Finder .app window floating over the Bridge CC window…  
    You're wrong there, Ann; it's not a Finder window but a TextEdit window.  Just look at your menu bar next time you invoke such a tease from within Bridge: the focus will have shifted to the TextEdit application.  That's why the window will show text but not images. 
    Clippings are one of the GREAT features of the Mac OS that are missing in Windows, and one very important factor that attracted me to the Mac almost thirty years ago. 
    I am very, very surprised that you haven't discovered its usefulness after all these years, as you are one of the savviest Mac user experts I've ever run across.

  • Calendar doesn't show what I type any more, why?

    Recently anything I type into the daily view
    calendar, dissapears. What could have changed?

    Resolved now, all ok!

Maybe you are looking for