Modifying Calendar.DAY_OF_WEEK issue

Hi,
I'm trying to get a report to run so that it gets data for the previous "business day" (M-F). So if a user comes in on Monday, he would get a report for Friday. However, I'm running into an issue where I do the following (after I already get the Calendar object set to the Locale.US, and EST TimeZone):
calendar.add(Calendar.DAY_OF_MONTH, -1);
System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
// check for Saturday/Sunday
if(calendar.get(Calendar.DAY_OF_WEEK) == 1)
  calendar.add(Calendar.DAY_OF_MONTH, -2); // FRIDAY
if(calendar.get(Calendar.DAY_OF_WEEK) == 7)
  calendar.add(Calendar.DAY_OF_MONTH, -1); // FRIDAY
System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
// WRONG DAY OF WEEK - I get a 3 not a 1 after the first .add() methodSo I'm not sure why it's acting strange, I still get the correct date (14) after the first .add but I'm kinda lost as to why the other comparisons do not work.
Thanks in advance,
Lior

Reply, I'm not sure why this is happening again, but I'm running the program (my system date is working fine and I'm getting the right date when I print out the getTime() method) and getting the wrong day of the week:
public class CalendarTest {
  public static void main(String[] args) {
     Calendar now = Calendar.getInstance();
     switch (Calendar.DAY_OF_WEEK) {
          case Calendar.MONDAY:
               System.out.println("MONDAY"); break;           
          case Calendar.TUESDAY:
               System.out.println("TUESDAY"); break;           
          case Calendar.WEDNESDAY:
               System.out.println("WEDNESDAY"); break;           
          case Calendar.THURSDAY:
               System.out.println("THURSDAY"); break;           
          case Calendar.FRIDAY:
               System.out.println("FRIDAY"); break;           
          case Calendar.SATURDAY:
               System.out.println("SATURDAY"); break;           
          case Calendar.SUNDAY:
               System.out.println("SUNDAY"); break;
          default: break;      
  } // end main
}I'm getting SATURDAY when running this test program. Why is this happening? I'm not sure at all.
Thanks

Similar Messages

  • Cannot Modify Calendar Entries from IOS Devices or iCloud

    I'm not able to modify calendar entries on either of my IOS devices, or when logged into iCloud on a Mac or PC. From iCloud, I receive a message stating that the entry modification cannot be saved due to a server error. From an IOS device, it simply reverts back to the original entry after I click "done."
    The only way I can modify entries is through Calendar on my iMac. This seems to have just stared within the past week or so. Anyone one else experiencing this issue?

    Hello Alex, 
    Welcome to the BlackBerry Support Community.
    Thank you for your question regarding the Calendar synchronization issue you are experiencing when attempting to complete a synchronization of using the BlackBerry Desktop Software.
    Have you attempted selecting Forget Device from the menu and reconfiguring the synchronization settings? What is your default Calendar currently set as?
    -FB
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click "Accept as a Solution" for posts that have solved your issue(s)!

  • IPhone 5, iCloud calendar reminder issue

    When I use the iCloud calendar on my iPhone 5 and make an event with a reminder set to "on time of event", it will sometimes just beep and flash a notice on lock screen for a few seconds and then the notice disappear from lockscreen.
    Sometimes though, everything works as it should and the notice is still there on lockscreen till I unlock the screen (or the event is over).
    All settings in notice center and mail/calendar is correct.
    When I use google calendar it always works!
    The problem was there from iOS 6.0 and is still there after update to 6.1
    I have been in contact with apple support who couldn't find any help at the moment.
    More people seem to have this according to this site: http://forums.imore.com/ios-6/244349-ios-6-calendar-reminder-issues.html

    Update: The problem occurs when I have connected my iCloud acount with calendar enabled on my iMac.
    It's like the iPhone 5 thinks I have seen the notice on my iMac and therefore removes it from the phone.
    This happens even if my iMac is locked/lockscreen.

  • Iphone 4s calendar alert issue

    I tend to put 2 alerts on my calendar events, one for 1 day before and the second one for 1 hour before (or some other on the day of event).  I have noticed that when I put in the first alert for 1 day before and then enter the second alert for 1 hour before and click done they have somehow been reversed, the first alert is now 1 hour before and the second alert is 1 day before.  I have to click them again and change them to the proper order, this usually take about 3 tries to get them to stay as I want them.  I can them save the event and all is good.  I was at the Apple store and the staff duplicated this issue so I know I'm not the only one experiencing this nuissance.  Has anyone else come across this?  I do hope the upcoming update will fix it.

    Update since Genius visit:
    1) Apple is working on an update
    2) There is no awareness at Apple of this calendar alert issue as a bug, hence it is not being addressed/worked on
    3) Solutions offered by Genius have not resolved this issue.
    Solutions offered by Genius, in order of which to try first:
    1) Delete calendar data from iPhone: Settings>iCloud>Calendars OFF and then restore data from iCloud: Calendars ON
    2) Reset iPhone settings: Settings>General>Reset>Reset all settings
    3) Restore to factory settings: Settings>General>Reset>Erase all content and settings, then restore data from iCloud and in-app backups.
    4) Use another calendar app (seriously)
    Of course, if the bug is actually part of the iOS software (could it be?) then no amount of erasing and restoring data will fix the issue.  I completed the first two options with no change, and am not willing to do the third option because I am not interested in going through the process of backing up, then restoring all my third-party apps.
    My solution: raise awareness of this issue with Apple, so that it can be worked on and fixed.   I have reported it as a bug through Apple's feedback module: http://www.apple.com/feedback/iphone.html and I encourage-- no, ask-- you to do the same, if you are experiencing this issue.  I provided a link to this forum topic to show the variety and detail of problems.
    Are you sick of missing alerts, fiddling endlessly, coming up with workarounds, paying for unreliable software, and not being responded to?  I am.  It's time to rally!

  • Blackberry Outlook Calendar Sync Issue

    We recently discovered a outlook calendar sync issue we can add items on the Blackberry and they will show up in Exchange. But you can’t change a calendar item from the Blackberry, e.g. if you create an item on the phone it will show up in Outlook, but if you use the phone to change the date or name of it Outlook will still show the old one.
    We are running BES 4.1
    We are running Exchange 2003
    Exchange and BES are installed and running on different servers
    OS of the server running BES 4.1 is WINDOWS 2003

    Hi, Please do not post duplicate threads.
    see here > http://supportforums.blackberry.com/rim/board/message?board.id=8300&message.id=37254#M37254
    You are posting your message in device threads meaning normal everyday users are going to read it, if you want advice from administrators, please post it in Blackberry Enterprise Server area.
    You also didn't put what full version of BES you are running! If you are running BPS, i will have it moved to the professional area.
    Thankyou
    If your issue is resolved, put a checkmark in the green box that contains the resolution.
    OR
    If it was just/or also really helpful - Give it a Kudos.. Go on Mate.. Help the rest of the clueless blackberry user world find their answer too..
    ~Gday from Down Under~

  • Calendar Consistency Issues

    We've begun seeing some calendar consistency issues on iPad devices. We are using an Exchange 2007 "back end", most of the users are using Outlook in cached mode on their desktop, and many will have another mobile device of one type or another. The consistency issues are appointments appearing in Outlook or being accepted in Outlook and not showing up on the iPad device. Every hardware vendor we've spoken with, including Microsoft, and RIM have emphasized the client/device side and implementing "best practives" such as the following:
    -minimizing number of instances of mail clients running against mailbox
    -minimizing delegates
    -having only 1 person notified of appointment
    -avoiding forwarding appointments
    -deleting changed recurring appt's rather than changing them
    -not accepting appointments from mobile device
    -running Outlook in online as opposed to cached mode where possible
    I'm hoping someone out there has found a "silver bullet" that goes beyond the suggestions we've gotten which are listed above. The problem is our high profile users that have the devices don't want to be told it's their behavior that's causing the problem!!!
    I appreciate in advance any ideas.

    Same thing happening on my iMac.  Can't do much on the computer.

  • About get(Calendar.DAY_OF_WEEK)

    Hi,
    I would like to ask if GregorianCalendar.get(Calendar.DAY_OF_WEEK) returns 0 for Sunday always, or it depends on the timezone and localization?
    Thanks.

    xpanta wrote:
    thomas.behr wrote:
    xpanta wrote:
    By RTFM-ing people you are not helping them.Obviously, I beg to differ.
    sorry to hear that, because it seems that your 2nd answer and tsith's answer gave me more information than the word "RTFM".
    But that word is a link to the API where it says what values that field can take.
    >
    >
    Much more important is the fact that the documentation does not mention any numeric values but constants >(which in turn implies that these values do not change). So, follow tsith's advice and code against the constants.thank you and tsith. This is something I didn't know, although I use it many times (just seems logical to do so)In general don't depend on anything that isn't documented in the API - the API documentation is a contract of sorts, but undocumented features might be changed or removed without warning.
    Good Luck
    Lee

  • Calendar alert issue

    Hi all,
    I've got a minor annoying issue. My wife (iPhone 4 with iOS6) and I (iPhone 5 wiht iOS6) share an apple account. On iCloud, we've got two calendars. The first is called "Calendar" which is there for us to put all of our general home stuff (birthdays, vacations, appts, etc) and is intended for both of us to use. I've got a second calendar called "Dan" which is just for me with a bunch of stuff she doesn't care about.
    Here's the issue. In Calendar, she clicked "Calendars" and deselected the "Dan" under "iCloud Calendars". The only other calendar her Calendar app now shows is our default shared calendar. So, anything I put on the "Dan" calendar no longer shows up... yay! HOWEVER, alerts from my "Dan" calendar still appear on her phone. In other words, if I put an event called "test" on JUST my "Dan" calendar with an alert to go off at 1:00, at that time, BOTH of our phones go off and display alerts. The Event still doesn't show up in her calendar though.
    SO, my question is, how can she make it so alerts from "Dan" calendar don't show up on her phone? It's annoying for her, and not cool for me if I want to put in an event that she shouldn't know about.
    Thanks,
    Dan P.

    Update since Genius visit:
    1) Apple is working on an update
    2) There is no awareness at Apple of this calendar alert issue as a bug, hence it is not being addressed/worked on
    3) Solutions offered by Genius have not resolved this issue.
    Solutions offered by Genius, in order of which to try first:
    1) Delete calendar data from iPhone: Settings>iCloud>Calendars OFF and then restore data from iCloud: Calendars ON
    2) Reset iPhone settings: Settings>General>Reset>Reset all settings
    3) Restore to factory settings: Settings>General>Reset>Erase all content and settings, then restore data from iCloud and in-app backups.
    4) Use another calendar app (seriously)
    Of course, if the bug is actually part of the iOS software (could it be?) then no amount of erasing and restoring data will fix the issue.  I completed the first two options with no change, and am not willing to do the third option because I am not interested in going through the process of backing up, then restoring all my third-party apps.
    My solution: raise awareness of this issue with Apple, so that it can be worked on and fixed.   I have reported it as a bug through Apple's feedback module: http://www.apple.com/feedback/iphone.html and I encourage-- no, ask-- you to do the same, if you are experiencing this issue.  I provided a link to this forum topic to show the variety and detail of problems.
    Are you sick of missing alerts, fiddling endlessly, coming up with workarounds, paying for unreliable software, and not being responded to?  I am.  It's time to rally!

  • Since downloading OS 6 for my iPad, my calendar keeps issuing repeated alerts - even though I didn't even initiate one.  Is there a way to stop this from happening?  Thanks for your input !

    Since downloading OS6 for my iPad, the calendar keeps issuing repeated & different alerts for events even when I initiated none.
    Any suggestions as how to stop this will be most appreciated.
    Thank you in advance !

    This is the same issue that has plagued me for years. I always thought that this was a Flash plugin issue, but it does occur on HTML5 as well. A friend of mine verified that this does not occur in Linux, but only on Windows. It would be great to have this fixed, as it's honestly the only thing that's making me use Chrome all the time, as I don't want to have multiple browsers open.

  • Outlook 2011 and mountain lion calendar sync issues... resolved (kinda)

    Okay... I never really post to these boards, but I'm fairly ticked off that OS X keeps tampering with MS Office and it's syncing with iTunes and, ultimately, my iPhone.  Apple support tried to push me onto the iCloud, but I'm not going to use that crappy feature. After many hours of trying to fix the calendar sync issue with MS Office 2011, I found a workaround:
    1.  Get the apple reminders set up to recognize the OS X Calendar program.
    2.  Confirm that your Outlook calendar data is recognized in the OS X Calendar program (it was always there for me)
    3.  Install MS Office 2008 (Entourage) --- You don't have to use it, but the older program still syncs with Mountain Lion.
    4.  Sync your iphone with itunes and ensure that your Calendars are erased (uncheck the Calendar sync box).
    5.  Click on the "Replace Information on this iPhone) for Calendars.
    6.  Re-sync the iPhone with iTunes.
    7.  The data should go up with no problem.
    IF you are still having problems...
    1.  go to OS X "Calendar" and Add a new calendar called "Home".
    2.  move the Outlook data to the Home calendar (just drag and drop).
    3.  Repeat steps 4-7 above.
    Since I've done these changes, everything directly syncs.
    Hope this helps, and don't lose faith.  MS will come up with some type of patch.

    Outlook 2011 is not compatible with iCloud, it won't work and your 'workaround' may affect iCloud clients on the same account.
    Don't use 2011.

  • Intermittent iphone activesync calendar/mail issues

    We are experiencing intermittent activesync calendar/email issues that are causing many of our iPhone users to miss meetings and have major trouble scheduling events from the iPhone. The main problem is that most of the time everything works perfectly until suddenly you realize that you missed a meeting or that your email is suddenly out of sync and you have no idea how long it has be like that.
    I have found several band aid "solutions" to temporarily resolve the issues:
    http://blog.fosketts.net/2008/07/10/how-to-set-up-iphone-exchange-activesync/
    http://blog.hltechsolutions.com/2008/07/iphone-activesync-calendar_24.html
    We are using iPhone Firmware 3.0 and higher on all iPhones on a Exch 2007 server
    We need a really solution for this ASAP

    I am on version 3.1.2 and am having many problems with ActiveSync. It often says connection to server cannot be established and prompts me for my password multiple times a day. I have checked with other iPhone users in the organization and many do not have problems. I have tried changing my password, deleting the ActiveSync profile and recreating, and restoring the iPhone. I am getting quite frustrated as are my IT peers as they have to unlock my Windows account every few hours. I need help please!
    This behavior seems to have started when I upgraded to 3.1.2. Before that I never had any problems.

  • New Calendar Sync Issue with new iPad2

    My calendar has synched flawlessly with my google calendar and Mac previously, but since adding a new iPad2 to the mix, I am having some issues.
    I noted today that when I made a change on the MBP, the iPad calendar was not updated during a sync. So I checked the settings and "sync calendars" was not checked. Odd since it always synched in the past.
    So I selected sync calendars and got the message that over 2000 entries would be added or modified on the MBP. I have also chosen to not sync events more than 30 days old but some of these items go back to 2006.
    An example.
    Event happening in April of 2008 shows no original date (whatever that means) so the modification is to add an original date of 12/31/00.
    I have no clue what this is about or why the iPad sync is not working correctly.
    Any advice would be much appreciated.

    try removing proxy settings on gprs connection and try again. Sounds like a proxy problem.
    I still own a NOKIA 6250 KUDOS others as You Would Like to be KUDOSed! There are only 10 kinds of people in the world, ones who digg binary and ones who dont

  • Calendar Constrain Issue

    I'm having a bit of an issue with the constraint feature on a Prompt. A little curious if what I'm trying to do is even possible
    I have 2 items on my prompt.
    #1. Date Selection (calendar)
    #2. User (drop down list)
    Now the User is constrained based on the Date selection. This works fine....BUT only when i press "GO". It’s almost like the Calendar doesn't post back when a new date is selected...so it ultimately doesn't constrain the drop down list until "Go" is pressed
    The real issue arises when I run the report once, then change the date and press "Go".
    If there happens to be a single User for that given date, the report will run against that 'new' user. However the User prompt will still display the old user from the first run until I manually change it. The Clients don't like this
    Is there any way to fix this?

    I believe what you are describing is the way OBI works. I haven't found a way to "fix" this so if anyone chimes in with the answer, I would be more than happy to learn what it is. But after reading some "best practices" books on OBI dashboard desgin, I read something that covers this issue that at least helps the user.
    In a separate section under the Report, place a Text object in the section. Use the Guided Nav. in the section properties and have it connect to the Report with the "If request returns nothing" radio button selected.
    Next, paste this in the text field:
    <center><font color="red"><h3><b>Please select a value from the prompt above and hit the "Go" button.</b></h3></center> Don't forget to check the HTML checkbox. Modify the test above as you see fit.
    Now the user is at least warned to select an appropriate value from the prompt.

  • I am unable to modify calendar events

      I have set up my Google account to sync with Calendar but I am unable to modify events. I tried to update an even t but the event reverted and lost the updated information after a molment.

    Permissions – Reset Home Folder (includes 10.6.8)
    Permission Issues - Troubleshooting
    You may need to rebuild permissions on your user account. To do this,boot to your Recovery partition (holding down the Command and R keys while booting) and open Terminal from the Utilities menu. In Terminal, type:  ‘resetpassword’ (without the ’s), hit return, and select the admin user. You are not going to reset your password. Click on the icon for your Macs hard drive at the top. From the drop down below it select the user account which is having issues. At the bottom of the window, you'll see an area labeled Restore Home Directory Permissions and ACLs. Click the reset button there. The process takes a few minutes. When complete, restart.   
    Repair User Permissions

  • Outlook 2013 calendar permissions issue

    Hi,So I've been bashing my head on something for a couple of days now and I need your help.We migrated from Exchange 2007 to 2013 on premise in the last couple of weeks and we now have some issue with some of the shared calendars.So the problem is, I gave full access rights to a mailbox to someone else and also gave that same person Owner permission on the shared calendar.In OWA, everything is ok, I can see all the details, edit everything, I even see the events colors.BUT in Outlook 2013, it's another story.I only see the details of the event without being able to modify and/or add anything.Here's what I tried so far :Disable Outlook cached mode - NopDeleted/recreated Outlook profile - NopDeleted all permissions for that user and recreated it - NopRemoving full access permissions and restoring them - NopUpdating Exchange 2013 to CU 8...
    This topic first appeared in the Spiceworks Community

    Hi,
    I recommend you refer to the following article to share your calendar:
    Share an Outlook calendar with other people
    Hope it helps!
    Thanks.
    Niko Cheng
    TechNet Community Support

Maybe you are looking for

  • There used to be a arrow next to the first site that would come up in the search and now it's gone how do you get it back?

    For instance I go to a biker site and once I put that in Google search it's the first one that comes up on the list of websites there used to be a arrow pointing at that site and as you would scroll down a arrow would be pointing at each site and I c

  • My apple id has been disabled, what do i have to do?

    Hi I having problems downloading music, films and tv programmes as your system advises that my Apple ID has been disabled. I haven't logged into my account for a couple of months so maybe that is the problem, can you please advise? regards, Darren

  • Warning Messages to be removed.

    Hi All, Can you please guide me to remove warning messages i receive while i enter previous dates in PO date, pricing date. Also info message received while entering in service rendered date. As these messages are creating hindrances in creating BDC

  • Date array and Sorting

    I have a date array that i created from a database.  I am trying to sort the dates into the correct order with the upcoming on top.... the best would be that after the date has passed it would go to the bottom of the list. Can anyone tell me if I am

  • Verify disk fails, verify disk fails

    Verify stops and the following is what I read: This volume Mac HD was found corrupt and needs to be repaired Error:  This disk needs to be repaired.  Start up your computer with another disk (such as Mac OS X install disc) then use disk utility to re