Error in Calendar.add (almost) evey last Monday of March

Is the following a known bug? I am running under Windows 2000 and using
C:\jdk1.4>java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
* Filename: CalendarBug.java
* Every last Monday of March (except those with a whole week after it),
* gives a wrong result when subtracting 24 hours with the Calendar.add function.
* These specific dates give -25 hours...
* Selected output:
* Set date: Mon Mar 26 00:00:00 CEST 2001
* -->Adjusted 24 hours: Sat Mar 24 23:00:00 CET 2001
* Set date: Mon Mar 25 00:00:00 CET 2002
* Adjusted 24 hours: Sun Mar 24 00:00:00 CET 2002
* Set date: Mon Mar 31 00:00:00 CEST 2003
* -->Adjusted 24 hours: Sat Mar 29 23:00:00 CET 2003
* Set date: Mon Mar 29 00:00:00 CEST 2004
* -->Adjusted 24 hours: Sat Mar 27 23:00:00 CET 2004
* Does anyone care to explain?
* The result is the same when substituting seedDate.add(Calendar.HOUR,-24) with
* - seedDate.add(Calendar.HOUR_OF_DAY,-24)
* - seedDate.add(Calendar.MINUTE, -24*60)
* Date Created: 25. september 2003 09:53:20
* Written by: Skjalg Bjorndal
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class CalendarBug {
    GregorianCalendar seedDate = new GregorianCalendar();
    public void lastMondayInMarch(int year, int month, int date) {
        System.out.println("   ------- Year: " + year + " ----------");
        for (int i = 0; i < 10; i++) {
            System.out.println("   ---------- " + i + " ----------");
            seedDate.set(year, month, date + i);
            seedDate.setTime(zeroTime(seedDate.getTime()));
            System.out.println("   Set date:          " + seedDate.getTime().toString());
            seedDate.add(Calendar.HOUR, -24);
            if (seedDate.get(Calendar.HOUR_OF_DAY) != 0) {
                System.out.print("-->");
            } else {
                System.out.print("   ");
            System.out.println("Adjusted 24 hours: " + seedDate.getTime().toString());
        System.out.println("");
    private Date zeroTime(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        // Zero out time:
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    public static void main(String args[]) {
        CalendarBug aBug = new CalendarBug();
        aBug.lastMondayInMarch(2001, 2, 19);
        aBug.lastMondayInMarch(2002, 2, 18);     // OK - hole week after last Monday of month
        aBug.lastMondayInMarch(2003, 2, 24);
        aBug.lastMondayInMarch(2004, 2, 22);

Thanks for both of your prompt replies!
The number of hours to be subtracted is configurable in a property file in the program in which the problem arose. I.e. it could be 1, 23, 24, 120 or whatever...
My solution will be to download 1.4.2, as kurisu1 pointed out would solve the problem.
Until we tested the rest of the code with 1.4.2, I will reprogram and use the seedDate.add(Calendar.DATE, -1); as a temporary work around.
Best regards
__Skjalg

Similar Messages

  • ICloud Server Error: Can't add/edit contacts + it overwrites AddressBook edits

    I originally posted this in the MobileMe forum. I am totally frustrated and disgusted with the unreliable and buggy iCloud. I am hoping smarter people than me can help resolve this. Thank you.
    My primary data source is/was my MacBook Pro. It was all synced to MobileMe. (Contacts and iCal). iCloud came along. I "upgraded" to iCloud {the frustrating process of "your account needs to be upgraded, create an appleID..." was a whole different pain}.
    To make life simple, I even allowed iCloud to be the source of data for my iMac as well as iPhone 4 and iPhone 4S by deleting everything and letting everything be populated from iCloud. Now, supposedly, all my contacts and calendar/reminder data is in iCloud and all the data on the iMac and iPhones if from iCloud.
    Except, I cannot make edits to contacts in iCloud or even Add a new contact. When I Add or Save an edit in iCloud, EACH time I get an ERROR and the error report going to Apple is given below.
    Worse, I spent an hour cleaning up the freshly downloaded contacts in the iMac's AddressBook. NONE of those changes went up to iCloud.
    EVEN worse, iCloud overwrote the changed fields back to the old/blank fields, wasting my hour of work.
    Adding cards in AddressBook on the computer also does not propagate to iCloud, though edits to or changes to iCal DO show up in iCloud. But, adds/deletes/edits to Contacts on iMac OR iPhones do NOT show up in iCloud.
    Your help appreciated. Regards,
    Imran
    ===
    This is from the iMac console when I tried to delete a contact:
    11/20/11 6:05:09.289 AM Address Book: Process com.apple.AddressBook deleting 1 contact
    11/20/11 6:05:10.045 AM Address Book: [CardDAVPlugin-ERROR] -getHomeInfo:[_controller containersAtURLs:{(
        https://MYNAME%[email protected]:443/########/carddavhome///MYNAME%[email protected]:443/########/carddavhome/
    )}] Error Domain=CoreDAVErrorDomain Code=1 "The operation couldn’t be completed. (CoreDAVErrorDomain error 1.)"
    The rest of the log is at: https://discussions.apple.com/thread/3508969 and not repeated here.

    I added this comment to a thread about trying to get rid of iCloud once it has been used... it is much harder than you'd imagine... I am sharing it here because it includes steps I took after the problem we are discussing above....
    ====
    I love Apple since it started and been a Mac user since it came out. Much that MobileMe was frustrating and had a lousy launch, I thought it was impossible to make something worse than MobileMe. Apple succeeded with this disaster, data destroying, heart burning, stomach churning and hours wasting beast called iCloud.
    See iCloud Server Error: Can't add/edit contacts + it overwrites AddressBook edits By IMRAN Happy to have your thoughts on how to solve that nightmare. My last attempt (manually restorying my 5000 contacts in AddressBook, then painfully manually deleting contacts in iCloud {Select All > Delete there gives Server Errors also}. Finally managed. Then resyncing the MacBook Pro to iCloud led to 1000 contacts NOT syncing and no way except manually listing each address list side by side to figure out which ones it missed pulling in. Horror. Disaster. Shame.
    For the user who says that turning off iCloud on the Mac and accepting its offer to delete data will delete data only on the cloud, sorry, but, unless I misunderstood you, that is dangerously wrong.
    Like an evil spawn of SkyNet and a PC Boot Sector Virus, once iCloud has grabbed your data IT becomes the master of your data, your digital life. Deleting stuff means the stuff on your DEVICE (e.g. MacBook Pro, where you created and have all the ORIGINAL data in that iCloud sucked in) is what will be destroyed. Be careful.
    If you're playing with this beast, not only make backups of your data in AddressBook and iCal, but invest in an external drive and clone your whole hard drive.
    I am literally having to make a decision tonight, keep my MacBook Pro as the master, and sync via iTunes to the iPhone 4S and 4. I have an iMac mostly for music and video, which it was "cool" to have synced iCal and AB on, though not regularly used. But, after the hours wasted with iCloud, and the repeated data loss, I can live without the iMac being a synced device.
    Hope this helps.
    Regards
    Imran Anwar

  • Help on calendar.add() adding -60 days

    hi all
    i am having problem with the add() in Calendar class. i try to get a date that is 60 days prior to the current date, and here is what i coded:
    Calendar calendar = new GregorianCalendar();
    System.out.println("current day : "+calendar.toString());
    calendar.add(Calendar.DAY_OF_MONTH, -60);      
    System.out.println("after adding (-60), the day is "+calendar.toString()); and here is the output of the print:
    --- getEffectiveDate ---
    current day : java.util.GregorianCalendar[time=1088608525321,areFieldsSet=true,a
    reAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/New
    _York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,last
    Rule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=36
    00000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayO
    fWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayO
    fWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=
    1,ERA=1,YEAR=2004,MONTH=5,WEEK_OF_YEAR=27,WEEK_OF_MONTH=5,DAY_OF_MONTH=30,DAY_OF
    _YEAR=182,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=5,AM_PM=0,HOUR=11,HOUR_OF_DAY=11,MI
    NUTE=15,SECOND=25,MILLISECOND=321,ZONE_OFFSET=-18000000,DST_OFFSET=3600000]
    after adding (-60), the day is java.util.GregorianCalendar[time=1083424525321,ar
    eFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInf
    o[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,tra
    nsitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000
    000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,sta
    rtDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,
    endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minima
    lDaysInFirstWeek=1,ERA=1,YEAR=2004,MONTH=4,WEEK_OF_YEAR=18,WEEK_OF_MONTH=1,DAY_O
    F_MONTH=1,DAY_OF_YEAR=122,DAY_OF_WEEK=7,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=11,H
    OUR_OF_DAY=11,MINUTE=15,SECOND=25,MILLISECOND=321,ZONE_OFFSET=-18000000,DST_OFFS
    ET=3600000]it looks like it only subtracted 30 days from current date. i wonder what happen to the 60 days. does anyone have any idea why? thanks for ur help.

    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
    Calendar calendar = Calendar.getInstance();
    System.out.println("current day : " + df.format(calendar.getTime())); // 6/30/04
    calendar.add(Calendar.DAY_OF_MONTH, -60);
    System.out.println("after adding (-60), the day is " + df.format(calendar.getTime())); // 5/1/04What's the problem?

  • Error Loading Calendar

    One of my locally created calendars is howing a little ! symbol next to it and I'm getting this message:
    Error Loading Calendar
    iCal was unable to load the calendar. The file might be corrupted or temporarly unreadable.
    You can try again later or reset this calendar
    Resetting the calendar will remove all calendar content.
    Options to Reset or Try again later are presented.
    Any help on this would be very appreciated.
    Thanks.

    Don't know why it happened but i came up with a workaround. my ipod calendar was still intact so i just deleted all the calendars in iCal, made new ones called the same thing and then dropped the .ics files from the ipod onto the calendar and voíla, all back to my last sync of a couple days ago.

  • HT1926 I have this error pop up while almost done installing, "An error occurred during the installation of assemble 'Microsoft.VC80.CRT,type="win32",version="8.0.50727.4053",publicKeyToken="1fc8b 3b9a1e18e3b",processorArchitecture="amd64"". HRESULT: 0x80

    I have this error pop up while almost done installing, "An error occurred during the installation of assemble 'Microsoft.VC80.CRT,type="win32",version="8.0.50727.4053",publicKeyToken="1fc8b 3b9a1e18e3b",processorArchitecture="amd64"". HRESULT: 0x80070422

    OK.  If both of you are Windows 7.  Make sure you go to Windows update (START button, type in Windows Update). Check for updates and update whatever that are available. (especially Microsoft .NET Framework 4 )
    After that see if you still get this error message.
    The last resort would be to unistall and reinstall the whole thing.
    Follow the steps below:
    1. Go to Microsoft website to fix install and Unistall problems. Click "Run now" from Fix it to remove all iTunes & related installer files:
    http://support.microsoft.com/mats/Program_Install_and_Uninstall
    Be aware that Windows Installer CleanUp Utility will not remove the actual program from your computer. However, it will remove the installation files so that you can start the installation, upgrade, or uninstall over.
    2. You should remove all instances of iTunes and the rest of the components listed below:
    it may be necessary to remove all traces of iTunes, QuickTime, and related software components from your computer before reinstalling iTunes.
    Use the Control Panel to uninstall iTunes and related software components in the following order:
    iTunes
    QuickTime
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Follow the instructions from Apple article listed here: http://support.apple.com/kb/HT1923 to remove all components
    3. Reboot your computer. Next, download iTunes from here:http://www.apple.com/itunes/download/ and install from scratch

  • Error loading calendar - try again later

    yesterday i noticed my home calendar was missing. So i had made a backup within iCal on 11/16/06 and one on 11/28/06 and whenever i choose "revert to backup" from either file it says database unchanged (with all the home stuff missing and one entry i'd made that morning still there.) i had our IT guy go back into the backup and get my calendar from november and now it's saying:
    "Error loading Calendar
    iCal was unable to load the calendar. The file might be corrupted or temporarly unreadable.
    You can try again later or reset this calendar. Resetting the calendar will remove all calendar content."
    is this just ruined or what? the IT guy said even my backups were corrupted so no point in trying to revert. What's up with this crap?
    Mary

    Don't know why it happened but i came up with a workaround. my ipod calendar was still intact so i just deleted all the calendars in iCal, made new ones called the same thing and then dropped the .ics files from the ipod onto the calendar and voíla, all back to my last sync of a couple days ago.

  • Job to run last monday of every month

    Hello Experts,
    I have to create job which should run last Monday of every month. We have function module to find last Friday of every  month. I can add 3 days to get last Monday.
    We have to specify the job or event in the "Start Condition" of the job, how can we achieve this?
    Any help?
    Thanks,
    Venky

    Hi,
    Hi,
    Please use the below function module to raisa a event
    CALL FUNCTION 'BP_EVENT_RAISE'
      EXPORTING
        EVENTID                     = p_event
       EVENTPARM                    = ' '
       TARGET_INSTANCE              = ' '
    EXCEPTIONS
       BAD_EVENTID                  = 1
       EVENTID_DOES_NOT_EXIST       = 2
       EVENTID_MISSING              = 3
       RAISE_FAILED                 = 4
       OTHERS                       = 5.
    IF SY-SUBRC = 0.
    write: 'Event', p_event , 'was raised.'.
    else.
    write: 'Event', p_event , 'could not be raised. check transaction SM62 if event has been changed or non existent'.
    ENDIF.
    else.
      write: 'No change is detected'.
    endif.
    if the function module returns the last monday of the month.
    Then the job can be based on this event.
    -Vikram

  • Error Message: "Calendar has unexpectedly stopped" while joining shared iCloud calendar.

    When attempting to join a shared iCloud calendar from a family member, I receive this error message:
    Calendar has unexpectedly stopped.
    An unexpected error has prevented this application from working properly.
    Details:
    ERROR
    SC.Store#find() must pass recordType or query
    The details also contain a large amount of diagnostic information which I have sent to Apple.
    Is there anything else I can do to prevent this error from occurring?

    I'm having the same problem on my wife's computer. I successfully joined several shared calendars from my account, and suddenly started getting this message on the last one. I've tried again repeatedly over the last 24 hours, including sending a new invitation, logging her out of iCloud website, etc.
    Did you find any resolution to the problem?

  • ¿How do I set the calendar to start week on Monday and not Sunday in my iphone?

    ¿How do I set the calendar to start week on Monday and not Sunday in my iphone?

    The jewish calendar does not have names for the days of the week. The week ends with the holy Sabbath (Saturday) and therefore the Sunday is the first days after Sabbath (Yom Rishon), the Monday the second day after Sabbath (Yom Sheini), etc.
    The Christians believe that Christ was raised on the first days of the week (Mathew 28:1, et al) AFTER the Sabbath was over. So their holy day is the Sunday and the working week starts on a Monday.
    The business days in the western world are numbered starting with the Monday as day number 1 (Timetables of Airlines, Calendars, even Microsoft Windows...).
    Unfortunately in the United States religious freedom extends to a level which is not understood easily by the rest of the world. Since the MAC OS X allows to change the first day from a Sunday to a Monday, one might wonder why Apple decided to give the iPhone a jewish touch.
    It could be supposed that this is the way of the least resistance. Only few complain about this issue, but if it were the other way around a lot of people would complain...
    PS: I agree with the others here: It is very, very annoying and more than once I entered an appointment into the wrong day...;-)

  • Finding Last friday and Last monday of current date

    Hi
    Please help me to get the Last friday and Last monday of current date using an sql query.
    If I am running query on 7th July 2008 ,it should give me Last friday as 07/04/2008 and Last monday as 07/07/2008
    I need to compare it with another date filed
    eg: Select * from employee where ReportedDate between [Last Friday] and [Last Monday]

    It works many times but fails for this scenario- If today is Friday and I run following query today, it throws today's date, which is incorrect. I need previous Friday's date to be returned everytime.
    select next_day (sysdate-7,'FRIDAY') Last_Friday from dual
    Edited by: user6402026 on May 22, 2013 1:43 PM
    Edited by: user6402026 on May 22, 2013 1:43 PM

  • Error while installing add on

    Hi Experts,
    error while installing add on
    in add on installation wizard
    setaddonfolder(c:\.....)returned 1
    even i tried as run as administrator
    also tried creating a new folder but same error is showing
    Please help

    Step 1:
    Ensure that the Company Databases are upgraded to the same patch as
    the SBO-COMMON.
    Please see the SAP Note 979083.Also
    check that the DB Version which is displayed in the 'Choose From'
    window is the same for all databases. Please select the Refresh button
    to ensure the information is up to date.
    Step 2:
    Ensure that the DI API is updated to the same patch as the databases.
    Please do follow the steps described below to make sure the DI Version
    is updated on the affected machine:
    1. Disconnect from the DI (close all AddOns)
    2. Deinstall the DI API via Add and Remove Programs
    3. Open the temporary folder via
    > Start > Run > enter %temp%
    4. Locate the folder SM_OBS_DLL and delete this folder.
    5. Install the DI API of the same Patch than the Software version of
    the system. The Setup.exe is located in the folder:
    ...\Packages\DI API
    6. Connect to the DI again.
    See SAP Note 870207.
    Step 3:
    Recreate the SBO-COMMON.
    0. Ensure that no user or addon is connected to any Business One
    database.
    1. Create a backup of the current SBO-COMMON.
    2. Delete the SBO-COMMON from the Server.
    3. Create a new SBO-COMMON by running the Upgrade.exe for the
    Business One Installation Files under
    ...\Packages\Upgrader Common
    Step 4:
    Reinstall the ServerTools. The installation files can be found under
    ...\Packages\Server Tools
    Step 5:
    Test if there are any open connections which might prevent the new connection.
    Please test to restart the server and connect to the database where you were getting the error first.
    I think this might resolve ur issue.

  • "Error in function: Add Table not found [131-183]" - TDS Addon Version 3.16

    While loading TDS Addon Version: 3.16 I am getting the undermentioned error:
    "Error in function: Add Table not found [131-183]"
    SAP B1, 2005B, PL 39.
    It also shows the message that it is successfully installed. When I try to access any of the screen the above messge pops up.
    This is very urgent kindly help me out.
    Edited by: Philip Eller on May 16, 2008 8:50 AM
    Edited by: Philip Eller on May 30, 2008 8:41 AM*

    Dear,
    The addon is a third party addon which was developed by CitiXSys. so the support is provided by the partner who developed the addon.
    Go to the vendor Citixys for further support will give you a quick reply.
    Regards
    Apple

  • Error with calendar database: Program version 4.2 doesn't match enviroment

    hi!
    im instaling jes in a windows 2000 machine and i get this error when trying to start calendar:
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Information: Log created (1156170958)
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: Sun Java System Calendar Server 6 2005Q4 (built Dec 27 2005) csadmind starting up
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: csadmind attempting to open Counters Database
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: csadmind successfully opened the Counters Database
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: HTTP Module is refreshing
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: csadmind is refreshing
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: csadmind is refreshed
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: HTTP Module has refreshed
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: csadmind argc=1 argv[0]=C:\Sun\CalendarServer\bin\csadmind.exe
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Notice: csadmind attempting to open Calendar Database
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Error: caldb: Error with calendar database: Program version 4.2 doesn't match environment version
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Error: caldb: caldb_InitializeEnvironment: dbenv->open returned 22
    [21/Aug/2006:16:35:58 +0200] jes csadmind[1752]: General Critical: Fatal error 70: Cannot open calendar database
    anyone have faced same problem?
    thanks in advance

    Hi Vyacheslav,
    its wierd that when I run db_stat on windows, for my environment, it works.... I installed Berkeley DB XML 2.4.16 from a self extracting package.
    When I tried running from my Linux box, the error message appear... The native library on my Linux box was built from the zip package dbxml-2.4.16.zip
    Arent they the same?
    Thanks!

  • PC Suite : "2 hours" error in Calendar vs. handset...

    Hi everyone
    Everything on my laptop (PC Suite) Calendar is 2 hours earlier than on my handset's Calendar!
    For example:
    a) If I enter an appointment (using PC Suite's "Calendar" function) to start at, for example, 4pm... and then SYNCH with my mobile (a Nokia 6086), on the handset's Calendar the appointment will start 2 hours earlier - at 2pm!!
    b) Similarly, If I enter an appointment (on the mobile) to start at, for example, 4pm... and then SYNCH, on my laptop (in PC Suite's "Calendar") the appointment will start 2 hours later - at 6pm!!
    Can anyone help me?  Thank you in advance for your ideas!
    ...Paul
    Solved!
    Go to Solution.

    I also have this problem.
    I always suspect a two hour error in calendar software to be a result of a bad module used to convert 24 hour time (military time) to 12 hour AM and PM (and vias versa).  My phone and PC are set to display military time.  Is this true of your use?
    If so, it would explain the apparent rarity of  this error being reoported.
    I have the same model.
    Message Edited by crews on 05-Nov-2009 05:51 PM

  • Exception:Error getting property 'add' from bean of type sample1.edit

    Hi when i try to build and run the applicaiton it is displaying that build and run is successful. But when i try to access the jsp page through the url then it is showing error as below.
    Exception Details:org.apache.jasper.JasperException
    Error getting property 'add' from bean of type sample1.edit
    Can anyone please help me out from this problem.
    Thank you in Advance.

    I solved the problem. The issue was everytime I was compiling only the JSP and the componenets couldn't recognize the bean methods.
    Now I am running the project after any changes.
    Thanks

Maybe you are looking for