Calendar Date Calculation

What's wrong with my following statement?
I always get compilation,
class XX
Calendar calendar = Calendar.getInstance();
Calendar cal1 = calendar.add(calendar.MONTH,1); //incompatible types error
Date expiry = cal1.getTime();
but I got the requirements asking for <identifier> in the 2nd version
class XX...
GregorianCalendar calendar = new GregorianCalendar();
calendar.add(calendar.MONTH, +1); //identifier need
Date expiry = calendar.getTime();
but it works when it is declared under
class {
public static void main(String[] args)
{  GregorianCalendar calendar = new GregorianCalendar();
calendar.add(calendar.MONTH, +1); //identifier need
Date expiry = calendar.getTime();
However, I am not going to declare it under main.
Pls help!

In the first two cases, you haven't put the statements in a method, where they belong. In the last, you did, so it worked. You can have methods other than main(), of course.
You should post real code and real error messages when you ask a question...

Similar Messages

  • 1 & 2 Year Calendar Date Calculations

    Hi All,
    I am a total newbie to designing forms so please bear with me.
    I am currently working with a lease form and i need to do the following:
    I want to be a to fill in a date field with a Lease Start date: ex.. "09/01/2010"
    and have a script or calculation output the corresponding 1 and 2 year Lease End Dates to separate date fields.
    which in this case would be 1 year "08/31/2011" 2 year "08/31/2012".
    I want it to verify that the dates are correct and account for leap years.
    I would prefer if this could be done in Formcalc, as I have no experience whatsoever in using Javascript.
    Thank you in advance for any help you guys can provide.

    I just created a sample foe someone else on this same topic. In this instance using Javascript is easier than FormCalc so that is what I used. We can take the date field and separate it into its components of day, month and year. Once we have the year we can add 1 or 2 to it and then simply put the date back together again to make a date. This way we do not have to worry about leap years ar adding 365.25 days. Have a look at the code ..it is pretty straight forward. If you have questions do not hesitate to ask. The code is on the click event of the button.
    Paul

  • Function module SD_SCHEDULING: delivery date calculation factory calendar

    Hi,
    When I create or change a sales order, system calculates the delivery time and date (ETDAT) using transit duration and factory calendar. Currently factory calendar says that transportation leaves every Monday, Wednesday and Friday. Unfortunately, function module SD_SCHEDULING calculates the delivery date using factory calendar dates, i.e. <b>NOT</b> using working dates.
    Function module reads the factory calendar from table TVRO (Routes) and field SPFBK (Factory calendar key) in subroutine GET_CUSTOMIZING, and saves factory calendar id in CS_SCHEDDU-TRANSIT_FC. The calculation itself is done later in function module DATE_CONVERT_TO_FACTORYDATE.
    For example, if transit duration is 3 working days, function module calculates the delivery date using Monday (first day), Wednesday (second day) and Friday (third day). Thus, the result is Friday, which is wrong. Result should be of course Wednesday (Monday first day, Tuesday second day and Wednesday third day).
    I'd like to use working days instead of calendar days. I am planning to recalculate the delivery date in some user exit, but before I start coding, I'd like to hear your opinion: <i>Is it possible to use working days instead of calendar days when calculating delivery date?</i> (I believe it must be, since my case is very normal). If it is, I assume that this can be achieved with IMG, but how and where?
    I am using SAP R/3 Enterprise.
    Regards,
    Jarmo Tuominen

    Hi jarmo,
    1. DATE_CHECK_WORKINGDAY
       Probably this FM may be useful to u.
    2.
    CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
            EXPORTING
              date                       = d
              factory_calendar_id        = '01'
              message_type               = 'I'
            EXCEPTIONS
              date_after_range           = 1
              date_before_range          = 2
              date_invalid               = 3
              date_no_workingday         = 4
              factory_calendar_not_found = 5
              message_type_invalid       = 6
              OTHERS                     = 7.
    regards,
    amit m.

  • Fiscal Calendar in Report Variant Dynamic Date Calculation

    We are switching from the standard calendar to a 4/4/5 calendar for our fiscal calendar. We have a number of batch reports that use dynamic date calculation in the variant to get Month-To-Date or Previous Month date ranges. Is there a way to convert these variants to use the new FiScal calendar instead of the regular calendar?

    thanks to answer , praveen.
    I know, VARI has name of FM , but not has Calendar ID.

  • Schedule Line Delivery Date Calculation with Transportation Scheduling

    Hi All,
    We are currently running into a problem where our Sales Order Schedule Line delivery dates are being pushed out too far into the future - because of the Calendar being used to determine the transit time.
    We have 'Delivery Scheduling' and 'Transportation Scheduling' activated for our Sales Document type
    We have Routes that are configured with a 'Transit Time' and a 'Factory Calendar'
    Order Scenario:
    'Factory Calendar' assigned to our 'Route' is setup with only one 'Workday' in a given week e.g. Wednesday
    Our 'Route' has a Transit Time of 2 days
    We create a Sales Order on Monday for a Material that is available in our Plant
    The 'Goods Issue' date is being determined correctly for the next Workday - being Wednesday
    The 'Delivery Date' is extending out over 15 days (2 Wednesdays into the future) - since it is working on 'Calendar Days' and not 'Actual Days'
    Does anyone know of a way (config or other) to only influence the 'Goods Issue' date with the 'Factory Calendar' assigned to the Route, and have the 'Delivery Date' calculated using the Transit Time on the Route and 'Actual Days' rather than Calendar days?
    All help greatly appreciated.
    Thanks,
    Ravelle<i></i>

    Hi Pathik,
    Thanks for your reply.  I have already maintained the Calendars I'm using for this business process in <SCAL> - same as <OY05>. 
    The problem I'm having though is that by assigning a Calendar directly to my route (which I doing to influence the goods issue date - using a 1 Working Day Calendar) it is also taking precedence in determining the Transit time - which in this case I don't want, as I want my Transit time to be determined using a 5 Working Day Calendar.
    I don't think this problem has a config option as a work around...I think the only possibility in this case is a development to achieve the results we need.
    Thanks,
    Ravelle

  • Calendar date & net due date (FI) PAYMENT TERMS - OBB8 Vendor Invoice

    I read many posts on SDN forum about the topic.
    Anyway, I didn't find a simple solution for that.
    My aim is is to calculate a net due date based on working days.
    So, If I've got a 30 days document days payment term  ("Deafult for baseline date" = Document date ; Additional Months = '2'), a Vendor Invoice (document date = 12.05.2011), by standard net due date will be 12.06.2011.
    FROM 12.05.2011 to 12.06.2011 =
    32 CALENDAR  DAYS         
    22 WORKDAYS (32 minus  10 holyday - 2 weekends)
    WORKDAYS PAYMENT TERMS  Within 30 workdays Due net
    Vendor Invoice  document date = 12.05.2011
    plus   30 workdays   =  DUE DATE  22.06.2011  (and not 12.06.2011)
    Can I obtain that with a standard functionality?
    Edited by: Roberto Buono on Jul 1, 2011 2:29 PM

    Hi,
    Sadly this is not available as standard.  As per your need the Net due date should be worked out by using a factory calendar; but what this does is it delinks the direct correlation between the number of days in the payment terms with the difference between the due date and baseline date.  I hope you are aware that Net Due date is not stored but is a variable calculated during run time in reports.
    There are four things you can try:
    1.  The simplest to do is: As the number of weekends are fixed; and if the intention is to give a 30 working day term, then add on the number of weekends and make the payment term effectively for say 40 days.  There will be marginal variations over what you want. Best part here is that config remains standard.
    2. All the receivable reports will use a function module (usually the same one) to calculate the net due date; enhance the FM and make it consider a factory calendar for calculating due date.
    3. Enhance the accounting interface, and in runtime; modify the days that are coming from the payment term; based on a factory calendar, and update the accounting document. This delinks the days mentioned in the payment term and the accounting document and may not be palatable.
    4. Enhance the accounting interface, and in runtime; calculate the due date and update the baseline date with it and make the payment term as "Immediate" yielding the desired due date. Not very elegant.  Alternatively add to the baseline date days equivalent to holidays and weekends and keep the days from payment terms constant and update the accounting document. Better...
    All four options have somes pros and cons.  I do not see any other means of acheiving what you want.  Maybe you could restrict users to a custom receivables/due date/ageing report which delivers what you want and lock the standard reports.
    Cheers..

  • PR delivery date calculation for TAB orders

    Hi All,
    1) The PR which is created via TAB item in the sales order - the delivery date for such PRs is equal to the delivery date in the sales order. This is happening only for TAB orders without BOM explosion in the sales order.
    2)In BOM exploded sales order - (meaning the parent item is entered in the sales order with item category TAP. ) -The sub components of this parent item is auto populate in the sales order. If any one of these sub components have item category TAB...then it creates a PR which has the delivery date equal to the "Planned delivery time" in the info record.
    Can anybody please explain why the PR default delivery date is different in the two cases explained above. Both are TAB items...the only difference is one is a stand alone TAB item and the other is via BOM explosion.
    Your help will be highly appreciated.
    Thanks
    Ashok

    Hi Sasy
    Delivery date calculation for MRP generated PR will follow the below settings
    1) Purchasing processing time in the Plant parameters in the customization and is calculated based on the Factory calendar days.
    2) Planned delivery time maintained in PIR and is calculated based on Normal calendar days
    3)GR Processing time Maintained in Material master record, calculated based on Factory calender.
    If you add up in the following sequence then you will get the exact delivery date.
    Purchasing Processing time + Plnd delivery time + GR processing time.
    Hope it will solve your  issue.
    Thanks / Karthik

  • How to use Replacement Path Variables to perform Date Calculations

    Hi Experts,
    Can anyone make me clear about:How to use Replacement Path Variables to perform Date Calculations???????
    Thankyou in advance..
    shankar

    In left panel select the time Dimension
    Then hit new variable in that
    give the Name and Description for the Variable
    In processing by hit Replacement Path
    In reference characterisitcs use Calendar Day...
    As ur intention is to use it for Date
    Then in adjacent tab use
    Replace variable with Query / Variable
    Then u can use Offset length and offset start for controoling the display of your variable.
    Use as single, multiple single, interval, selection option as uwish
    HIt okey
    and you are good to go

  • Date Calculations - Adding 1 to the day and adjusting month/year

    Hi all,
    I have a date field in MM/ DD/ YYYY format. If I add 1 to the DD (day) field, and I hit the end
    of the month/year I need to adjust the MM and YYYY accordingly.
    Is there is an existing class/method in the JAVA API that would handle somthing like this??
    If so , I can't find it..... I don't want to re-invent the wheel creating a Date Handling routine just
    for this program.......
    Thanks very much

    This is overkill... (and sorry that this post is over a year later than the original post... hopefully somebody will benefit from it :)
    Calendar.getInstance() by default instanciates a GregorianCalendar
    object. (check the src).
    Therefore:
    Calendar cal = Calendar.getInstance();
    cal.setTime(d); // where d = java.util.Date or java.sql.Timestamp
    cal.add(Calendar.DATE, numberOfDays);
    return cal.getTime();
    public static java.util.Date
    adjustDateBy(java.util.Date d, int numberOfDays) {
    java.util.GregorianCalendar cal = new
    java.util.GregorianCalendar();
         cal.setTime(d);
    cal.add(java.util.GregorianCalendar.DATE,
    numberOfDays);
         return cal.getTime();

  • How can I get missing contacts, notes, calendar dates and reminders that are just on my old iphone onto the iCloud for transfer to my new iPhone upgrade?

    Dear wise & wondeful people:
    How can I get missing contacts, notes, calendar dates and reminders that are just on my old iphone onto the iCloud for transfer to my new iPhone upgrade? Half of my contacts, notes, ect. were on my iCloud so have happily moved to my new iPhone but the rest are completely resistant. For example, on my iCloud I have 14 missing contacts starting with the letter A alone, however they are happily viewable on my old iPhone 4S and won't budge over into the iCloud.
    There are also 3 notes missing yet still acessible on my onld iPhone 4S, the list goes on.
    Your help would be most appreciated. Thank you so much.
    BCHR

    Hi BCHR,
    If you are having issues transfering your content from your old iPhone onto iCloud so it can be transfered to your new iPhone, you may find the following articles helpful:
    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device
    http://support.apple.com/kb/HT2109
    iCloud: Troubleshooting iCloud Contacts
    http://support.apple.com/kb/TS3998
    iCloud: Troubleshooting iCloud Calendar
    http://support.apple.com/kb/TS3999
    iCloud: Notes overview
    http://support.apple.com/kb/PH12081
    Regards,
    - Brenden

  • ITunes Calendar data doesn't match Outlook's.  How can I fix?

    I have a new iPhone and just recently discovered that the Calendar is not updating, 
    probably since the first time I synced.  And even then it was using old calendar data which 
    doesn't currently show up in Outlook.   (Contacts sync perfectly.)  Applecare took me 
    through their 1st and 2nd-level support troubleshooting and said they couldn't do anything more.  
    They suggested possible corruption of outlook.pst. 
    One glaring example: I used to have 3 calendars in Outlook: "Bridge", "Calendar" and 
    "Others".  I recently deleted all but the one called Calendar, but all 3 still show up in 
    iTunes, even though I've uninstalled/reinstalled iTunes twice.  Only "Calendar" shows up on 
    the iPhone, but it has old data.  I think the data it's displaying has not been refreshed 
    since 9/23/11, when I moved the outlook.pst file to a location in My Documents for easier 
    backup, but that doesn't really make sense since the Contacts update just fine.  (I've had 
    an iPad for about a year, and it's behaving the same as the iPhone now; the Calendar used 
    to update properly.)  Another possible clue: the iPhone shows two instances of one 
    particular recurring appointment.  I don't recall ever having two instances of it in 
    Outlook and wonder if that could be the problem.  I removed it altogether from Outlook and 
    that didn't help.
    I've done extensive testing with a new Windows user account and Outlook, and the calendar 
    syncing seems to work fine.  I've Googled "iPhone calendar won't update" and similar and
    haven't found anything that works for my situation.
    I'm running Office 2003 on Windows XP.  I do NOT use Outlook for mail.

    I was having the same problems after downloading 10.4.1 IStore would only download half way then nothing attempted reinstall no goood checked the Diagnostics with IPad connected, indicated no errors. more than a few hours browsing possible solutions. Found one stating 'Remove all Itunes connected software, i.e. Bonjour, ITunes, Safari etc from PC via the Uninstall Safely Feature and ReInstall. Hey Presto it worked now no issues.
    Good Luck. I am using Windows 7.
    That's my problem exactly, but I can't find the: ''Uninstall Safely Feature and ReInstall''. Where is that??
    Thank You

  • HELP - I've lost all my Calendar data, most of my Notes, and other issues

    In priority order:
    1.  Sometime in the last two days my iPhone 4S, with IOS 7.0.4, lost all my Calendar data except birthdays from Contacts.
    2.  Most of my Notes are lost except those from PC.
         WRT the above, iPad data is still intact.  
    3.  IOS 7.0.4 crashes apps A LOT! Even Apple apps.
    4.  IOS 7.0.4 is slow.

    Resolved items 1 &amp; 2 by rebooting the phone.  I am happy that it resolved, but it shouldn't have happened n the first place.

  • HT1296 I have a problem synching calendar data between my iPhone 3GS iOS 5.1 & Outlook 2007 on MS7.  The basic calendar is OK but the birthdays (little box icon) are a day early & cannot be changed to the correct date. How can I fix this?

    I have a problem synching calendar data between my iPhone 3GS iOS 5.1 & Outlook 2007 on MS7.  The basic calendar data transfer is OK but the birthdays (little box icon) are a day early & cannot be changed to the correct date. The birthday entries in my Outlook contacts have correct dates.How can I fix this?

    The following peocess corrects the calendar entry:
    edit the contact & change the birthday, save the change; edit the contact & change the birthday to the correct value, save the change again. The calendar entry then displays on the correct date.  Alternatively as a temp solution I can just de-select the "birthdays" calendar which stops the icon being displayed.
    Thanks for your advice, I think that it's n going to be a slow process to fix all the entries for not much return.

  • Working day to factory calendar date

    Hello Experts,
    I wish to get the factory calendar date, specific to a factory calendar, based on a working day.
    Basically, if i pass say 4, then i want to get the date for the 4th working day based on a specific factory calendar.
    Can someone throw some light on possible function module that i can use in BW ?
    Thanks

    That's what I was giving you, you give the working day and the factory calendar and you get the date, or you can use this function and you can do it the other way:
    (Unless I'm completely missing your point here...)
        CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
      EXPORTING
        CORRECT_OPTION                     = '+'
        DATE                               = G_WORKAREA3-CREATEDON
        FACTORY_CALENDAR_ID                = L_S_PLANT-FACTCAL_ID
      IMPORTING
    *   DATE                               =
       FACTORYDATE                        = L_FCDATE
      EXCEPTIONS
        CALENDAR_BUFFER_NOT_LOADABLE       = 1
        CORRECT_OPTION_INVALID             = 2
        DATE_AFTER_RANGE                   = 3
        DATE_BEFORE_RANGE                  = 4
        DATE_INVALID                       = 5
        FACTORY_CALENDAR_NOT_FOUND         = 6
        OTHERS                             = 7.
      ENDIF.

  • ICal sycing calendar dates to iPhone

    Hi,
    When I plug the iPhone into the mac via USB and open iTunes, the calendar dates in iCal do not get synced across. I have gone into iCal and looked for a way to send dates to the phone, but without success. Can anoyone help, please? iTunes does send contacts - just not iCal dates.
    Thanks!

    I finally got it fixed with a little help from some related posts online.
    - Delete any files with 'cache' in the name that are in ~/Library/Calendars
    - Launch iSync, go to Preferences, and do Reset Sync History
    - Log out and log back in
    I don't know if it's one or both of the first two items, but it did the trick.

Maybe you are looking for

  • BEx Formula Use of 'Logical And' and Calculation for Gross Margin

    HI Bex gurus. Having an odd time with what should be a simple formula to handle the display of gross margin (GM). The goal here is to display GM% properly and the requirement is as follows If GM <= 0 then 0.0   Else If GM > 0 and Sell > 0 then ( ( se

  • I can't see any video in WebBrowser, Visual Studio

    I work on a WebBrowser in Visual Studio. I press "Start Debugging" , i write the site(ex. YouTube), get in a video and i see: 1.Script error with URL: https://s.ytimg.com/yts/jsbin/spf-vfld6zcp2/spf.js, no line, no char, no code. Just "Script Error".

  • Messages on Macbook Pro Screen Share not working

    Hi so on messages my friend is trying to share her screen with me and it is not working. When i added her it isnt letting me share my screen or ask to share hers. do we both need to have the same account type? how do i get it to work? and do i put in

  • ISight camera built in - good quality?

    Hello, I am about to purchase the 24 inch cinema display for my new Harpertown 3.0 Ghz mac pro 2008. I already bought the Nvidia GT 120 and wanted to know is the isight camera thats built in a much better camera than say, rocketfish which is a 3rd pa

  • Importing playlist to another computer

    hi all, i received my mbp today and think its bloody awesome! just had a quick question though. on my xp desktop i have itunes which has not only a playlist for my music but also the playlists of my parents and younger sibling. now that i have my own