Add 21 days to a date field in JSP

Hi.
How can I add 21 days to a String field containing a date value in JSP. I managed to get the string field without problem with the following codes :
java.text.SimpleDateFormat formatdate = new java.text.SimpleDateFormat("dd-MMM-yy");
java.util.Date currentTime_1 = new java.util.Date();
String bDate = formatdate.format(currentTime_1);
I would like to add 21 days to the field bDate.
Please advice.
Thanks.

As far as I know we cannot manipulate on the formatted date i.e. on a string value. but you can add/deduct days from a date and then format
it to get same result. you can try this out
java.text.SimpleDateFormat formatdate = new java.text.SimpleDateFormat("dd-MMM-yy");
java.util.Date currentTime_1 = new java.util.Date();
Calendar cal = Calendar.getInstance();
cal.setTime(currentTime_1);          
cal.add(Calendar.DATE,21);          
String bDate = formatdate.format(cal.getTime());          
System.out.println("formatted date "+bDate);
-Nagasree

Similar Messages

  • How to add 2 days to a date field?

    How to add 2 days to a date field if a Saturday was selected on a different date field?
    Thanks

    I am attempting to add a date field and then have a another field add an amount to a box if the date is less than 30 days. Later I want to update the form to have the today's date is less than 10 days.
    Early Registration Fee is $10.00 if posted by February 25, 2008
    Late Registration Fee is $20.00 if posted by March 17, 2008
    It seems simple, but, when you get to be 71 years old, it seems difficult. Any help will be appreciated.
    Here is a link to the form I'm working on:
    http://www.aworldwide.com/Gideon/Convention_Registration.pdf
    I am using a trial version of Adobe Acrobat 8.
    Thanks,
    Andy Anderson

  • Add 90 days to a date field.

    Hi All,
    I have a form page in which i have a field called date. The requirment is like this whenever i come to this form page the date field should 1st check the sysdate and add 13 weeks or 90 days to it and display it there. It should be like this whenever user comes to this page the date field gets loaded like this and display there. Need help to do this.
    Thanks in advance.
    Regards

    But i want this field to be dynamic. This date field is date picker. If i select 15th May from date picker it should populate 14th august. Any suggestions on thisIs this concept of selecting one date and having a completely different one appear going to be clearly understood by users? From a usability/accessibility perspective it may be a better idea to use 2 items, with the initial selection being made in a date picker and the computed value appearing in a separate display/read-only item.

  • How to Add 20 days to a date field

    Dear All,
    I am struck badly on Date manipulation. If somebody has any ideaz on this let me know.
    I want to add some amount of days to system date and then compare it with another date.

    Hi capo9999!
    There are two class to easy and fast manipulate date variables: Calendar and GregorianCalendar.
    You must to read documentation about because there are many details to consider. Date variables has a special structure and do not confuse with "Date class" wich can be used with Calendar and GregorianCalendar.
    An example:
    Calendar today = new GregorianCalendar(); or
    Calendar now = Calendar.getInstance();
    create a new date structure with current date and to manipulate these variables there are methods to add an amount to components. Another example:
    now.add(Calendar.DAY_OF_MONTH, numDays);
    It's amazing to work this way.
    Best Regards.

  • Add days to a date field on adobe form

    Hi,
    I have to add 15 days to a date field how i do that on javascript or formcalc?
    Thank you in advance.
    Miguel

    Hi,
    The below is in js code.
    I had a caluclated date time field on the screen which displayed the current date.
    The below code will just add 15 days to the day part of the date.
    for moving it to month if its more than 31 is to be handled by you.
      var valArray = this.rawValue.split("/");
      var newDate = valArray[1] + 15;
      var actualVal = Date.parse(newDate+"/"+valArray[0]+"/"+valArray[2]);  
    var dateType=new Date(actualVal);
    this.rawValue = dateType;
    Hope this helps you out, let me know if you need any more info.
    Cheers,
    Sai

  • Add Days to a Date field

    Hi all,
    I have the following requirement:
    I have a date field 0calday and the user would like to add a specific no.of days to it, like for example 10 or 15 days. Then we use this computed date field in calculations in the query. Could you please help and let me know how we can no.of days to a date field? And also how we can compute no.of days between two date fields?
    Regards,
    Ashmith Roy

    Hi Ashmith,
        When the user enters both date and no. of days, and if you want to calculate no of days from the user entered date I think you can go for an exit where you can use the available function module which calculates the no of days from starting of the month for the given date. Then you can add up the days entered by the user and use another available function module which converts it to the dat format again based on the given days and the old date. I don't remember the function module names but i am sur ethey are available.
    If the above thing is made possible then I think getting no of days between two dates is not a problem. Well i hope this will help you.

  • What is the best way to add a day to a Date object?

    I have come across numerous examples on adding a day to the CURRENT date, using the Calendar object. However, what I need to do is to add a day to a Date variable.
    Can someone tell me how to do that? I tried to set the value of my Date variable into the Calendar object, but, it appears that for the current JAVA version, they have deprecated the getYear(), getMonth() and getDay() methods for the Date class.
    Really appreciate your suggestions.
    Thank you in advance,
    SiowLing

    I haven't seen the OP express a concern over how to create/obtain the Date object (he could be using "new Date()" given the emphasis on "CURRENT"). Milliseconds is fine too if that's what you have (for example from a java.sql.Date).
    So the way to add a day to a Date object (the OPs original question) is to:
    - set the Date on a Calendar using setTime
    - add 1 to the DATE field of the calendar
    - get the Date from the Calendar using getTime
    Obviously you're right if the OP doesn't have Date object to start with, but just the "numbers" for year, month, day.

  • How do I add 364 days to a date?

    HI,
    I'm trying to add 364 days to a date on a form I've created.
    I've tried this method using form calc on the EndDate field but no success, just errors.
    EndDate=Date(InvoiceDate.getFullYear(),InvoiceDate.getMonth(),InvoiceDate.getDate()+364)
    Can anyone help please?

    The "InvoiceDate" is a character string and not the number of days from the epoch date for the "InvoiceDate". You first have to convert the "InvoiceDate" character string value to the number of days since the epoch date by using the "Date2Num()" function. Once you have the "InvoiceDate" as the number of days since the epoch date you can add the additional days before using the "Num2Date()" function to convert the adjusted number of days back to a date string.

  • Working days between two date fields and Changing Factory Calendar

    Hi,
    I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
    I have written the routine using factory calender and its working fine except for two problems now:
    1. If any one of the date field is empty then teh rsult should be zero.
    2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
    I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
    I am new to ABAP. Please help me how i can achieve these for below code.
    DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
          IS_HOLIDAYS TYPE ISCAL_DAY.
    DATA: T_DATE TYPE SY-DATUM,
          P_DATE TYPE SY-DATUM.
    DATA : X_DATE(4) TYPE C.
    DATA: CNT TYPE I.
    REFRESH : IT_HOLIDAYS.
    CLEAR : IT_HOLIDAYS.
    T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
    P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
    CALL FUNCTION 'HOLIDAY_GET'
    EXPORTING
    HOLIDAY_CALENDAR = 'CH'
    FACTORY_CALENDAR = 'CH'
    DATE_FROM = P_DATE
    DATE_TO   = T_DATE
    TABLES
    HOLIDAYS = IT_HOLIDAYS
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND = 1
    HOLIDAY_CALENDAR_NOT_FOUND = 2
    DATE_HAS_INVALID_FORMAT = 3
    DATE_INCONSISTENCY = 4
    OTHERS = 5.
    DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
    X_DATE = T_DATE - P_DATE - CNT.
    RESULT = X_DATE.
    Please help
    Regards
    Zabina
    Edited by: Syed786 on Nov 2, 2011 9:15 AM

    Hi Zabina,
    Try this function module  'DURATION_DETERMINE'.
    Give the factory calendar and unit as DAY
    With regards,
    Rajesh

  • How to add one day to a Date?

    Hi,
    What is the simplest way to daa one day to a Date object?
    Thanks.
    Pengyou

    You use a database query just to add one day
    to a Date object? I wouldn't call that the "simplest"
    way at all.I was going to suggest firing off an email to the naval observatory and having them carry out the calculation, emailing the result back (maybe using JMS, not sure - web service possibly?) but the OP's way is simpler.

  • Add 60 days to a date

    Hi!
    I have a date object called "CLOSED_DATE" that I get from av database view. I would like to add 60 days to this date.
    If CLOSED_DATE = "20080501", the new date should be "20080629", that should be put into a variable (NEW_DATE) for futher use
    Thanks for all the help!
    Best regards
    Helge

    H helge
    1 Go to close date & right click on it.
    2 now on restriction select closing_date & again select it
    3 now select 'Set offset for variable" & add 60 in that column.
    the variable is ready to use. just save it
    Assign points if useful
    Cheers
    SM

  • Click event to add (or subtract) a day to a date field

    I have a form that is giving me a little trouble. I want to be able to input a start date in one field, then input a number of days in another field, and then have it calculate a date that is that number of days away from the start date. The form is actually working ok for the most part, but there are a couple of issues I'm having.
    1. The end date is not calculating immediately upon exiting the number of days field. You have to tab all the way back to the start date and only when you exit that field does it calculate the end date. I need it to calculate when you exit the number of days field.
    2. I have added a little (+) and (-) button to be able to increase or decrease the date by one day. This works, but the problem is, I want to do this in the background. Meaning, I want the calculated date to change, but the # of days field to not change.
    So say I enter 12/1/2010 in the start date. Then I enter 1 in the # of days field. When I tab to the Calculated date field, it should immediately change to 12/2/2010. Then, if I click (+), the Calculated date field should go up to 12/3/2010, but the # of days field should stay at 1.
    I've uploaded a sample of what I have figured out so far here:
    https://acrobat.com/#d=v4c4KKdj0hesicxO8yO1pw
    Thanks so much for any help I can get on this!
    Jo

    I think this is what you are after. I moved the logic to the calculate event of the target date and added a numeric field to hold the result of adding/subtracting (called 'delta').
    // form1.#subform[0].date2::calculate - (FormCalc, client)
    var date1 = Date2Num(date1.formattedValue,"MM/DD/YYYY")
    $.rawValue = Num2Date(date1+days+delta,"MM/DD/YYYY")
    You could make 'delta' hidden.
    Steve

  • How do you add a Day to a Date Referenced from another field

    I tried this and all of the other Date Calcs in the other posts but can't get it to work. The field (Read Only Text or Calculated Date field:
    var MyDate=xfa.resolveNode("form1.#subform.RepeatableSubform.#subform.StartDate")
    if(HasValue(MyDate)) then
    Num2Date( (Date2Num(MyDate.formattedValue, "EEEE, MMMM D, YYYY") + 1), "EEEE, MMMM D, YYYY")
    null
    endif
    Any Suggestions?

    Try it like this...
    Num2Date( (Date2Num(MyDate.rawValue, "YYYY-MM-DD") + 1), "EEEE, MMMM D, YYYY")

  • Add 30 days to a date

    How do you add 30 days to a user inputed date parameter?

    Hi,
    Create Date Parameter.
    ->From select expert select that field.
    ->From dropdown select is in the period from second dropdown select Next 30 days
    ->Click ok
    ->Refresh report.
    Regards,
    Shweta

  • How to set date +120 daye to one date field

    Hi,
    I have 2 fields one is Close date(Item style is Message Layout) and Quote Valid Until(Item Style is Date Field).After opening the page Close date will come automatically. Now My requirement is need to put Close date+120 days to Quote Valid unti field. Pls let me how to do this one and pls provide Sample code....
    Thanks in advance,
    Hanimi....

    Hanimi,
    Use Below Code
    //Convert the fetched date to calendar date and use the below method.
    import java.util.Calendar;
    public class CalendarAddExample {
        public static void main(String[] args) {
            Calendar cal = Calendar.getInstance();
            System.out.println("Today : " + cal.getTime());
            // Subtract 30 days from the calendar
            cal.add(Calendar.DATE, -30);
            System.out.println("30 days ago: " + cal.getTime());
    }Regards,
    Gyan

Maybe you are looking for

  • Assign to desktop option not showing up for a few programs

    Hi!  Well Assign to desktop is a great feature.  The problem I am having is that it does not show up under options for several programs.  It does show up with others.  Two of the programs it is not showing up with are Lightroom 4 and SpeedGrade from

  • App Store taking too long?

    Hi Yesterday I purchased (well, I thought I did) an application in the App store and right after I entered my credit card details and confirmed the payment, I got a text message as a receipt of payment. However, instead of EUR 12, it only deducted EU

  • CATA: Time sheet: Transfer to target componets

    Could you please please give me an overview of what CATA (t-code) does? I have done some config in sandbox: I booked time in cat2 with a sender cost ctr + activity type and receiver cost center in ECC 6.0. With out running cata (t-code), I was able t

  • Authentication on an IDSM-2?

    I have a requirement to have Authentication on our network devices using RSA Secure tokens or restrict it's mgmt interface from the network. So far I am using AAA through the ACS to accomplish this but I can find nothing about AAA for the IDSM-2. Doe

  • Static routes within VRF

    Is there a limit to the number of static route one could use within a VRF ? We have a large customer connected to MPLS VRF based backbone and due to various limiting factors this customer uses static routing from a PE-CE perspective. We have been exp