Calendar's add(field, amout) method - is it intuitive?

This may be quite obvious, but my current project relies mainly on the use of this one method.
What I mean by "intuitive" is, if I say:
Calendar c = calendar.getInstance(); //Get current date...
c.add(c.DAY_OF_MONTH, 7); // Add 7 days onto the current date...If we are on, say the 31st of the month, and I add 7 days, will it roll the date correctly? Does Java take into account leap-years and the fact that February only has 28 days (most of the time!)? I'm writing an app that will automatically generate machine maintenance requests on a particular day based on a pre-defined schedule, so it is very important that I can calculate the next date on which a request is to be raised...
Thanks in advance for your help - even if you tell me to go read the API (the reason I'm asking is because I couldn't see anything mentioned about it in the API, and because DAY_OF_WEEK et al are stored as int values, I was concerned it may just be adding to the int value without checking!).

I'd just like to point out, in a vain effort at
defending myself, No need. You're doing fine. We just needed a little clarification on what you're trying to do.
One thing is for sure--you want add(), not roll(). Roll will never change a higher order field then the one you're rolling. For example, if you roll() +1 month in December of 2006, you'll roll to January 2006. What you want to do is add(),n +1 month, which will bump Dec. 06 to Jan. 07.
Now, to clarify your rules--you want to add one month, and then, if the day of the week doesn't match (which it only will in Feb.), add enough days to get to the next occurence of that day of the week.
Does that sound right? This is my interpretation of your clarification a couple of posts ago.
A couple of things to note:
1) This rule will mean that in some months, there will be no service calls. For instance, in your example, service on 3/30, then next service is on 5/5, so no April service call. That's fine, if that's what you're business rules call for. I just want to make sure you noticed that implication of the rules you described.
2) The rules you describe amount to adding 5 weeks in every month except non-leap-year February, in which case it's the same as adding 4 weeks. Therefore, if it's acceptable, I'd recommend just picking either 4 or 5 weeks and always adding that. It will keep it simpler. 4 weeks mean some months get 2 calls, 5 weeks mean some months get none. You have to accept one or the other if you want to always service on the same day of the week, or else you have to complicate your biz rules with something like "...except if it means that a month will get no calls (or two calls), then adjust earlier (or later) to ensure exactly one call each month."
Note that the tricky part here has nothing to do with Java. It's in precisely and completely defining your business rules. Once you have that, the Java part is straightfoward.

Similar Messages

  • IPhone calendar appointments set to local calendar, and need to switch to exchange calendar. Have to edit each appointment one at a time and change to exchange calendar. Is there any method to edit all appoints in my calendar at once?

    iPhone calendar appointments set to local calendar, and need
    to switch to exchange calendar. Have to edit each appointment one at a time and
    change to exchange calendar. Is there any method to edit all appoints in my
    calendar at once and change the calendar setting?

    Not sure this will work but if you go into the Keyboard preferences, then click the Keyboad Shortcuts tab, and then the '+', you can add your own shortcuts for any application.  I am not sure what happens if you try to override an existing shortcut since I haven't tried using this.
    Edit/Update:
    Probably against my better judgement I'll also throw this out there - there's an Unsanity haxie called Menumaster which might also allow you to do what you want.  Against my better judgement because personally I stay clear of haxies.  It's (all haxies) probably almost certain to break in Lion.  They always do with each major release.

  • Duplication of attributes in Add Fields dropdown of  Advanced Search

    I am instantiating a secondary VO twice in the View Criteria. This leads to a duplication of query able attributes in the Add Fields drop down.
    Is it possible to override certain method in af:query, and suppress the attributes appearing in the Add Fields drop down.

    Unchecking the queryable attribute would remove the attributes from the Add Fields drop down all together. I need to avoid duplication and display the attributes only once.

  • How to copy sap standatd report to add fields and to make it work

    Hi experts,
        Can you tell me how to copy the sap standard report to add fields.
    I copied regular way including all includes also, but the porgram not activated and also every field started with %
    exp : data %dtab type standard table of /1BCDWB/IQ000000008078 with header line.
    Thanks

    Local object yes.
    I realise you're not an abaper, but if you got one in, he could simply create a subclass of /SAPPSSRM/CL_FY_NUMBER  (assuming it's not been made final) and override only the method that needs changing.  ( if it is final, then you have to use composition, but again, that's pretty straight forward ).  The point is, that copy a class rarely, if ever, needs to be done.  That's one of the major points about using classes.  If you use subclassing or composition, only small amounts of code need to be copied - which means if SAP change other bits in a new release, you automatically get them, thereby reducing the risk of an upgrade mucking up your cloned class.
    I'd be extremely nervous about having any code that had been implemented by a non-developer, being put into productive use.
    matt

  • How can I modify the Contacts Template to display additional fields with out selecting "add field" everytime?

    How can I modify the contacts template in either iCloud, my iPhone, or my iPad to display additional fields that I always use ... example: How can I get Job Title to always be a fillable field with out selecting "add field" everytime?

    Let the HairSalon implement the java.lang.Comparable interface. You'll need to write code for
    public int compareTo(Object o1, Object o2)
    The compare method would cast the Objects to HairSalons and return the difference in price.
    Then use java.util.Arrays.sort(Object []);

  • How to add fields to already loaded cube or dso and how to fill records in

    how to add fields to already loaded cube or dso and how to fill  it.can any one tell me the critical issues in data loading process..?

    This is sensitive task with regards to large volumes of data in infoproviders.
    The issue is to reload of data in case of adjusted structures of infoproviders.
    Indeed there are some tricks. See following:
    http://weblogs.sdn.sap.com/cs/blank/view/wlg/19300
    https://service.sap.com/sap/support/notes/1287382

  • How to ADD field in iview ?

    hi,
    in portal-iview i want to add a field.
    when i go to 'portal-content -> open the iview with right click -> preview' and then
    do ctrl-alt-right-mouse click i got to the customizing of the fields.
    i know how to HIDE fields there, but i don't know how to add fields ? in the list
    of the fields the necessary fields are available, BUT i only have to options:
    hide -> YES or NOT PERSONALIZED
    any ideas ?
    reg, Martin

    Gopal,
    the root element of this fields does NOT have the option 'decorate'.
    it is the quoata overview of ESS : sap.com/ess~quotas
    the top of the tree has option 'decorate', but this is above the necessary table where
    i select the data.
    my adrl is 
    martin.svik(at)denzel.at
    maybe we can 'change' some screenshots where you can send me yours and i can
    send you mine to explain it in a better way
    reg, Martin

  • How to add fields to Structure in Report Painter

    Hi All,
    We have a requiremnt where we need to add 2 fields ( profit center-PRCTR & description-CEPCT-LTEXT ) to structure CCSS. This structure is attached to library 1VK.
    Is it possible to add fields directly to a structure or do I need to create a new structure and attach it to a new library.
    If any one of this is possible, how can I do this ?

    Hi ,
    u can do it in both the ways , but i am not much sure abt second option.
    Useful Tcodes are GR21.
    Regards
    Prabhu

  • How to add fields in a z table

    hi experts !
    i have to add a new fields to an already existing Z table. how can i add field? do i have to delete all other entries and create new ones so that the entry in the new field also gets created.?
    akanksha

    Hi,
    You have two options to enter data type while creating new field in table.
    1. User standard data types i.e. mandt, kunnr etc..to use it u need to press  "Predefined type" button present on top of table fields.
    2. User custom data elements...this data elements you creates when you want to have data field specified to your required length.
    Hope this will help.
    Sumit

  • Add fields to Existing DSO and DS in R/3

    Hi Friends,
    I have got to change my LO datasource which is running on production, 2lis_va_vatim, i need to add 2 fields to the exisitng DS from Comm Stru, so could anyone point me inthe right direction, Hoow to Add the fields with out disturbing the production,
    and the same way i need to cgane my DSO aswell for new fields, please tell me how to meet this.
    Thanks,
    Kiran.

    Hi Kiran,
    Before applying your changes in Production do the below steps:
    1)run V3 job as immediate, which picks data to delta queue and delete the acive V3 job.
    2)run the IP which loads data to BW(Delta IP).
    3)Apply your changes to the 2lis_va_vatim and DSO.
      i)Do the changes(adding your fields to 2lis_va_vatim and DSO)in DEV and active the 2lis_va_vatim and DSO.(insert this in transports).
    ii)first apply the R3 transport and then BW side.
    4)from now on wards your 2 fileds will get populated in BW side.
    5)Maintain the V3 job for 2lis_va_vatim in R3.
    If you need any clarification how to add fields to 2lis_va_vatim and create transport req pelase check the below article.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/2050db8b-9d90-2c10-2980-b13a4b0938f6
    Hope this helps.
    Regards,
    Venkatesh.

  • Add fields in KOB2 & KSB2 report in selection screen as well as output

    Dear All,
    I have an issue in which i have to add fields in KOB2 & KSB2 report.
    i need to add below fields to KSB2 report.
    1) Internal order
    2) Vendor
    3) Purchasing group
    I also need to add profit centre in selection screen for KSB2
    Similarly for KOB2 i need to add below fields
    1) Cost centre
    2) Vendor
    3) Purchasing group
    I also need to add cost centre as input for KOB2 report.
    I have gone through note 325546 "CO line item reports: Creating a user-defined field" which can be helpful.
    However i am not sure as to how do i add fields in input screen as required.
    Other alternative is to create a Z report however when i try and copy the report both KOB2 & KSB2 call same report "RKAEP000".
    I am not able to get as to how do i differentiate the call of different screens when ZKOB2 is called or when ZKSB2 is called.
    I could identify " c_item_group" field having different values however i couldnot get a proper logic as to how correct screen can be called based on input
    Please suggest .
    Thanks,
    Ronak

    Hi Raymond,
    The note 747588 is good as soon as you are adding fields from the same table only.
    When I have added additional table into KAEP_SCOVP selection view below COVP (just because the extra fields I need are not in COVP) they will show up in KOB1 as selection criteria, but not getting saved.
    Any idea if any ABAP should be regenerated or what extra steps are required when adding more tables into Selection View?
    Thank you!

  • How to add field to the header for FBL5N ALV report

    Hi,
       I need to add fields to the customer line item display ALV report(FBL5N) header part.Right now there are four fields in the header like customer, company code, name and city, after that I need to add first name last name and phone no. Can any one tell me where exactly I need to add and populate there fields to be appear in ALV output list.
    Thanks in Advance
    Swapna

    Yes I have tried, I have place a break point in that perform but it does not stop. I think that is not the correct place to added and populate fields. That routine is for populate selection screen ranges single and multiple values and parameters only.
    Thanks
    Swapna

  • I already have a valid payment method for my iTunes account, but can't get past the Family Sharing setup prompt telling me to add a payment method . What to do?

    I already have a valid payment method for my iTunes account, but can't get past the Family Sharing setup prompt telling me to add a payment method . What to do?

    I had the same problem and found a bunch of others did, too.  Unfortunately all the posts had no responses!  Anyway, I previously had my payment method linked to my paypal.  I tried changing it to my credit card and it worked.  Don't know if there's a bug with using paypal but that seemed to be the culprit for me.  Good luck!

  • Can you add fields that are manually maintained.

    I'd like to be able to add fields to my MAP Toolkit's inventory. For example, adding Asset and Warranty fields, to keep track of this information. I'd be maintaining the data manually, which is fine since it doesn't change very often. Is there a way to extend
    the toolkit to include these types of fields?
    So far the only solution I've been able to think of is to generate reports, convert the .XLS to .CSV, and then use PowerShell to merge the .CSV with a file containing the static information. This would be quite an undertaking as I'd need either different
    scripts, of different logic paths, to deal with the multiple reports available from the toolkit.
    Thanks
    Jim Winner

    The reports are generated using queries that are in stored procedures. I suppose it would be possible to modify the query so that extra columns would be created, but I don't know how you would get the data into MAP.
    Please remember to click "Mark as Answer" on the post that helps you, and to click
    "Unmark as Answer" if a marked post does not actually answer your question. Please
    VOTE as HELPFUL if the post helps you. This can be beneficial to other community members reading the thread.

  • How to add a finder method in the container manager Bean in the weblogic6.1

    in the environment jbuilder6 andweblogic6.1,use container manager entity Bean,it can automatic generate the findAll() method,I want to add a new method to find an element in the home interface,such as findByName(),name is a element of a table of the database.in the weblogic-cmp-rdbms-jar.xml,this is part of the fiile:
    <finder>
    <finder-name>findAll</finder-name>
    <finder-query><![CDATA[ (= 1 1) ]]></finder-query>
    </finder>
    <finder>
    <finder-name>findByName</finder-name>
    <finder-param>java.lang.String</finder-param>
    <finder-query><![CDATA[ (=name $name) ]]></finder-query>
    </finder>
    It can successfully compile the findAll(),but it is wrong when compile the findByName(),as follows
    "www.ejbgrpx": Method Name: findByName
    "www.ejbgrpx": Invalid specifications for a WebLogic RDBMS CMP EJB.
    "www.ejbgrpx": ERROR: Error from ejbc: weblogic.ejb20.cmp11.rdbms.finders.IllegalExpressionException:
    "www.ejbgrpx": While trying to process Finder
    "www.ejbgrpx": Parameter Types: (java.lang.String)
    "www.ejbgrpx": WebLogic Query: (= name $name)
    "www.ejbgrpx": Finder Expressions: ()
    "www.ejbgrpx": Could not parse WLQL expression: (= name $name) null
    "www.ejbgrpx": ERROR: ejbc found errors
    thank you

    The finder methods that you are referring to are only simple finder methods. If you would like to add specialized finder methods, you can make your entity bean with bean managed persistence and not container managed. If you are using EJB 2.0, your entity bean with container managed persistence can use EJB QL for finder methods. You can search for this topic and/or download the EJB 2.0 specifications
    Hope this helps

Maybe you are looking for

  • HT1539 How can a digital copy be used in a household with multiple apple ids, synced on the same computer?

    How can a digital copy be used in a household with multiple apple ids, synced on the same computer?  I want to put a digital copy on my device, and on my wife's device. Please help.

  • I cannot share my music with family with new iTunes

    I have followed all of the steps to share music between my account and my husband's account, but cannot transfer music.  I can't transfer purchased music or music I downloaded from a cd. I have followed all of the proper steps to do this, but I am no

  • Color Printer, not printing

    I have two printers,HP color laserjet 2550Ln and Laserjet CP1525nw color. Both do not seem to want to print from FireFox using either the WEB Print Button or FireFox menu print menu bar selection. Both Printers take the commands but when the page com

  • One application installing another Jar

    Is it possible for one j2me application to install another one (or start the installation of another one)? If so, how? Thanks!

  • Rootpre.sh on AIX

    I am currently running 10.x on a production server and need to install a seperate 11.x instance. When I ran the rootpre.sh it barked that it wants me to shutdown all the current databases. Is this my only option? Is there any chance of the new rootpr