How To Add Number Days in jsp

Hi,
I want to add number of days in a date string using jsp.
<%--
    Document   : try5
    Created on : May 20, 2008, 6:00:20 PM
    Author     : thamaraiselvan
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        String datetxt="2008-05-20";
        %>
    </body>
</html>How to add 30,90,180,365 days in that String datetxt value.
Thanks Alot....

Hi,
How to format a string value into a Date.
I typed the following code .but its gives a exception.
<%--
    Document   : try5
    Created on : May 20, 2008, 6:00:20 PM
    Author     : thamaraiselvan
--%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*,java.util.Date,java.util.Calendar,java.text.SimpleDateFormat" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>JSP Page</title>
    </head>
    <body>
        <%
        try
        String datetxt="2008-05-20";
        int e=30;
       // calendar.set(Calendar.DAY,calendar.get(Calendar.DAY)+30);
       // Calendar cal = Calendar.getInstance();
        //Date today = cal.getTime();
        SimpleDateFormat fmt =new SimpleDateFormat("yyyy-MM-dd");
        String thamu = fmt.format(datetxt);
        out.println(thamu);
        catch(Exception e)
            out.println(e);
        %>
    </body>
</html>Exception Like This :
java.lang.IllegalArgumentException: Cannot format given Object as a Date .
After Formatting to date i want to add 180 days from '2008-05-20' .
Please Help me...
Thanks Alot....

Similar Messages

  • XSLT Mapping: how to add one day to TimeStamp

    Hello Experts,
    My requirement is to add one day to current timestamp. Used $TimeSent to get the currenttimestamp. In Expired field, the need to add one day
    say Created= 2011-03-30T20:29:13Z
           Expired = 2011-03-31T20:29:13Z
         <xsl:param name="TimeSent"/>
         <created><xsl:value-of select="$TimeSent"/></created>
         <expired>2011-03-31T20:29:13Z</expired>
    How to add one day to the current timestamp. I am new to XSLT mapping and need some help with the code.
    Thanks
    Shikha Jain
    Edited by: Jain Shikha on Mar 30, 2011 8:34 PM
    Edited by: Jain Shikha on Mar 30, 2011 8:36 PM

    Hello All,
    Thanks for your reply. i tried the function and the code is working when i am testing in stylus studio. But the same code gives error when i  tested the xslt mapping in PI (Error: TransformerConfigurationException triggered while loading XSLT mapping).
    $TimeSent function is working when code is tested in PI , but it doesnot give value in stylus studio. Also Current-dateTime() function is doesnot give value in PI but works in stylus studio. Is there any difference in the functions used in stylus studio and XSLT mapping in PI?
    Also if i remove the code used for function(to add one day to timestamp), and use constant value(2011-04-02T23:24:56.763Z)the code is working fine in PI. Please help me to find out where the code is going wrong when tested in PI.
    Below is the XSLT code i am using
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ds="http://xsltsl.org/date-time" xmlns:functx="http://www.functx.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xsl:function name="functx:next-day" as="xs:date?">
          <xsl:param name="TimeSent" as="xs:anyAtomicType?"/>
          <xsl:sequence select="xs:date(current-date()) + xs:dayTimeDuration(&apos;P1D&apos;) "/>
       </xsl:function> 
    <xsl:template match="/">
          <xsl:param name="TimeSent"/>
          <soapenv:Envelope xmlns:olsa="http://www.skillsoft.com/services/olsa_v1_0/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
             <soapenv:Header>
                <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                   <wsu:Timestamp wsu:Id="Timestamp-191900" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Created>
                         <xsl:value-of select="$TimeSent"/>
               </wsu:Created>
    <wsu:Expires>
         <xsl:value-of select="concat(substring(functx:next-day($TimeSent) ,1,10) ,&apos;T&apos;, current-time())"/>                  </wsu:Expires>
                   </wsu:Timestamp>
                   <wsse:UsernameToken wsu:Id="UsernameToken-19030197" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                      <wsse:Username>ABC</wsse:Username>
                      <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">XYZ</wsse:Password>
                      <wsse:Nonce>erDTBNoUWv7GdHDaErrLwA==</wsse:Nonce>
                      <wsu:Created>2011-02-15T23:24:56.763Z</wsu:Created>
                   </wsse:UsernameToken>
                </wsse:Security>
             </soapenv:Header>
             <soapenv:Body>
                <olsa:GetMultiActionSignOnUrlRequest>
                   <olsa:customerId>ABC</olsa:customerId>
                   <olsa:userName>XYZ</olsa:userName>
                   <olsa:actionType>launch</olsa:actionType>
                   <olsa:assetId>222499_eng</olsa:assetId>
                   <olsa:groupCode>testgrp</olsa:groupCode>
                </olsa:GetMultiActionSignOnUrlRequest>
             </soapenv:Body>
          </soapenv:Envelope>
       </xsl:template>
    </xsl:stylesheet>
    Thanks
    Shikha Jain
    Edited by: Jain Shikha on Apr 2, 2011 9:51 PM

  • 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

  • How to add a day to Date() ( i.e 2002Oct10 to 2002Oct11 )

    Hi anyone, How to add a day to Date().
    <%
    String R, fulldate;
    java.util.Date Rdate = new java.util.Date();
    R = Rdate.toString();
    String DD=Rdate_string.substring(8,10);
    String MM=Rdate_string.substring(4,7);
    String YY=Rdate_string.substring(24,28);
    fulldate = YY+MM+DD;
    //ie. fulldate = 2002Oct10 but I want it to be 2002Oct11
    %>
    pls. help and thanks a lot.

    Hi,
    Please replace the following line in your program,
    String DD=Rdate_string.substring(8,10));
    with
    String DD=String.valueOf(Integer.parseInt(Rdate_string.substring(8,10)) + 1);
    This will work fine. Basically what this code is doing is that, it will get the Integer from the String, increment it by 1 and then change the integer to the String again.
    Hope this helps,
    Rajat,
    OTN Team

  • How to add some days to the current system date

    can anyone help how to add some days to the current date i.e if today is 3-12-2007 and if v add 15 more days then the output should be 18-12-2007

    RajeshChandan wrote:
    First of all thanks a lot ,and coming to the question i dont mean to change the sysdate instead i want to write a prg. where after entering the current date it should effect with the no.of days that i have given but not the system date .if u can answer please reply for thisAh, I see. In that case, you can use an instance of GregorianCalendar and use it's add(...) method to add days, months, years etc. to it.
    http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html
    Good luck.

  • How to Add 15 Days to the current Date in eCATT

    Hello eCATT Guru's,
    How to add 15 days to the current date in eCATT.
    I have changed the Date format to mm/dd/yyyy.
    now i want to add 15 days to the sy-datum.
    How to do that.do any one know?
    Thanks in Advance,
    Raj

    Check out this link -
    http://help.sap.com/saphelp_46c/helpdata/en/d7/e21a50408e11d1896b0000e8322d00/frameset.htm
    It gives details about DATE variables in CATT. Hope this will help you out.
    ashish
    Reward points if you find this helpful.
    Message was edited by: Ashish Gundawar

  • How we add Grace days to net due date

    Hi,
    How we add grace days (eg one week) to net due date? This is only for particular customers.
    Regards,
    Shaik

    Hi Azeen
    Try this way. I assume that you want to know how much is due from customers as on a particular future date, that should come between today and that date. For preparing the liquidity forecast for the month, I use the following method for estimating the recoveries from the Customers and payments to Vendors and it works quite well for me.
    Let's say for Customers you want to forecast the collections that would come in the month of Jan from today until 31 Jan'09. Use the FBL5N Report, using the 'Open Item Key Date' as a future date, in our example - 31 Jan'09. Change the layout of the report by including the feilds 'Net Due Date' and 'Arrears after Net Due Date'. Sort the report on the Document Date, this being the baseline date. Now in the 'Arrears after Net Due Date' you will find the overdue days, which would be equal to the difference between the Date of the Report (31 Jan'09) and the Net Due Date of the Open Item. Thereafter, use the filter for 'Arrears after net due date' and click on the icon for 'multiple values'. Exclude the range of days, by assigning the lower and the upper limits. Lower Limit will be in minus, for those invoices that would still not be due upto 31 Jan'09 and the upper limit will be 7, since you would be granting a grace period of one week and consider all those invoices as not due upto 31 Jan. Once the filter is set, the report will exclude the open items as per the filter and provide you with a fairly accurate estimate of collections for the period/month.
    Let me know if it works for you.
    Regards

  • How to add get Day value in a Date object?

    Hi,
    I am writing a sql statement that has two date values. One I am getting it from the database. The format in the database is MM/DD/YYYY. My first question is how do I convert the format into the java date format, YYYY-MM-DD. The second question is I need to find out what the day is and add 1 to it. How do I get Day value in a Date object?
    Thanks.

    Look at "SimpleDateFormat" and "parse" in the archives.

  • How to add 15 days to the current date

    Hi everyone,
    I have the following doubt.
    I stored the current system date in to a variable.Now I want to store the date which is 15 days after the current date in to a new variable.
    ie current date:1-aug-09
    later date:1-aug-09 + 15 days ie 16-aug-09.
    Plz help me in solving this problem.
    Thanks & Regards,
    srinivas

    jaligamasrinivas wrote:
    I used String variable to store the current Date.
    Now in new string variable i want to store the date after 15 days from current dateSee reply #2. String is not the right type, to be doing date arithmetic, just like it wouldn't be the right type to do numeric arithmetic. You wouldn't store integer values as strings and ask how to add them up, would you?

  • 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.

  • How to add number of years to date

    Hello,
    How can I add a number of years (age) to a date (not the current date, the birth date, chosen from a DatePicker).
    Thank you,
    Ioana.

    Wow, that was fast :)
    Sorry for the double post, wasn't sure the first one was published.
    Thanks a lot, I've managed to add the the age correctly.
    Ioana.

  • How to add number of desktop

    I have two user in my MBA. One use account with 4 desktops. But another user account only with 1 desktop. May I know how can I add more desktop?

    Enter Mission Control, move the cursor to the top, right side of the screen.  A tab will slide out of the right side with a + sign on it.  Click that to add another desktop.
    Regards,
    Captfred

  • How to add number of boxes checked?

    Hey guys,
    I saw some other posts on this topic but I am new to spreadsheets and can't figure this out.  I have a bunch of boxes that I "check" and at the bottom I want it to automatically add the total checks together so I know the total.  How do I do this? I selected them and dragged the "count" button over but it won't add them up.
    Thanks for the help!

    Columns on a table are identified by letters. You can see the letters when you click on any cell in the table.
    "The formula is
    =COUNTIF(B,TRUE)"
    "This formula will count all the instances of the value TRUE in column B."
    Which column does the formula above count? Where is that column named in the formula?
    Your current formula, copied from your previous post, is:
    "=COUNTIF(F,TRUE)"
    ...and you write:
    "Only problem now is that it is only working for one column.  There are two columns and the one on the left is adding up perfectly"
    Which column is it "working for?"  Which column is "the one on the left"? Where is that column named in the formula?
    What is the only difference between the two formula above?
    What is the name (letter, not the label) of the second column of checkboxes that you want to count if they are TRUE (checked)?
    Knowing that name (letter), what is the only change you should make in the formula so that it will count the TRUE (checked) boxes in that column?
    Regards,
    Barry

  • 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.

  • How to add number to excel sheet work book cell?

    I am trying to create an excel sheet dynamically. I am able to create and populate the data as well.
    But in one of the cell I have to add 1.0 value. Since I have added this as a new Label(...), after opening the excel sheet I can see an icon in the cell with message as "Number in this cell is formed as a text".
    SO I have changed Label to Number while adding to cell.
    I am using the format as "#.#". Othen than 1.0 everything I can see in the cell as x.y format. Like 1.2, 5.7 etc...
    But for 1.0 I can see as "1." only.
    Is there any way to write 1.0 to cell as a number.
    I am using jxl.jar for excel.

    I have jxl supported api.
    It supports formating the numbers.
    It has NumberFormat class to support formating.
    NumberFormat format = new Numberformat("#.#");
    WritableCellFormat cellFormat = new WritableCellFormat(format);
    excelSheet.addCell(new Number(1, 0, 1.0, cellFormat);
    Api for Number : Number(int column, int row, double value, Cellformat ft);
    If I add other than 1.0, data is displayed properly in the sheet.
    1.2, 4.5, 3.567 --> 3.6 etc...

Maybe you are looking for

  • Battery on MacBook doesn't work after Firmware Update

    Hi - I updated my MacBook with the Firmware Update as soon as it popped up on the screen. My MB has been exhibiting the random shutdown problem. Everything worked fine until I restarted my computer, and now it will not operate without the AC adapter

  • Companion CD for 10g R2 upgrade in Ebiz

    Can anyone know why we require Companion CD in 10gR2 database upgrade in Ebiz 11.5.10.2 setup.

  • Representing Smallworld network in Oracle Spatial

    I'm trying to determine the network capabilities of Oracle Spatial. We are discussing whether it has equivalent capbilities as the Smallworld data model. Is there currently a translator that can convert Smallworld data into Oracle Spatial, without lo

  • Buying computer for Solaris 8 - any advice?

    I am buying computer for Solaris 8.0 and would appreciate comments/experiences from ppl who have installed Solaris on Intel platform. What to buy and what NOT to buy for smooth installation (if that can be done) ... :) <br> Anyone managed to install

  • ICE Content.

    Hi All, I have recently implemented KM transports refering some blog. I am not able to c the Ice folder under Root in KM in QA and PRD. I achieved success when i performed the same in DEV Portals. I have used the following steps to activatte the Ice