Converting Date to a calender and vice vera

Hi
i've a Date object which i need to add a Day to and than convert it back to a Date object. i need the use the Calendar.add() method but i dont see any method of Date that returns a Calendar.
i wish to do something like this :
Calendar c = Date.getTime();
c.add(day);
Date plusDay = c.getDate();Thanks
D

You use the somewhat misnamed setTime and getTime methods of the Calendar class for that - as:Calandar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, 5);
Date newDate = c.getTime();This would make a new Calendar, set its date/time to the current date, add 5 days to it and then get its date/time to the "newDate" Date.
Hope that helped
Lee

Similar Messages

  • Convert char to ascii code and vice versa

    HI
    Is there any function module to convert char to ascii code and vice versa.
    Thanks in advance

    Hi,
    be careful if you have unicode running in your system. URL_ASCII_CODE_GET is platform-dependent so it will return the internal HERX representation of the character in your system - which is hopefully and in most cases ASCII.
    Under unicode, we use double-byte characters here. I tried this function and the result CHAR_CODE is '00' regardless what character I specify for TRANS_CHAR. But the coding is so simple I corrected resultig in this sample code:
    [P]
    convert p_form to ASCII (internal) representation
      DATA:
        l_ofs TYPE syfdpos,
        l_len TYPE sy-linsz,
        l_ascii TYPE i.
      FIELD-SYMBOLS:
        <x> TYPE x.
      l_len = STRLEN( p_ascii ).
      DO l_len TIMES.
        l_ofs = sy-index - 1.
        ASSIGN p_ascii+l_ofs(1) TO <x> CASTING.
        l_ascii = <x>.
        WRITE: l_ascii.
      ENDDO.
    [/P]
    Here, for each character of string p_ascii, the internal (ASCII) representation is determined and written to the output list.
    Regards,
    Clemens

  • How to convert ascii value into character and vice versa

    Hello the java world people,
    I want to convert each characters from my array into their corespondent ascii value and vice versa, how can I do that ?

    The term "ASCII" is often used very loosely.
    Java char values are UNICODE and the ASCII codes are indentical to UNICODE characters in the range 0 .. 127. UNICODE values 128 and above don't have coresponding ASCII values, though 128-255 corespond to ISO-8859-1 which is one of the encodings often called "extended ASCII".
    As shown above you can covert between chars and coresponding int value simply with a cast, but you should be aware that the more exotic characters will not give you sensible values.

  • Strange problem in converting between XML to string and vice versa

    i have an application that needs to send an XML document
    over the wire. For this reason, I need to convert the
    doc into a String at the sending side and back to Doc
    at the receiving side. This document is stored in a "CLOB"
    column in a table in the database. I use XDK to retrieve
    this entire row (including the CLOB - hence this is an XML
    document which has a column that itself is an xml document in
    string format - this is just the clob read in by XDK).
    Thus the row looks like
    <ROWSET>
    <ROW>
    <col1> A <col1>
    <CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
    </ROW>
    </ROWSET>
    When I convert this document into String and back, one of the "<"
    tags in the clob column document gets changed to "&lt;" and hence
    the parsing fails! I have used the latest label of the XDK build
    to get the latest parser jar but still i have the same problem.
    I am using the following routines for the conversion.
    /* for converting document to string */
    public static String convertToString(XMLDocument xml) throws
    IOException
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    xml.print(pw);
    String result = sw.toString();
    return result;
    /* for converting string to document */
    public static XMLDocument convertToXml(String xmlStr)
    throws
    IOException,SAXException
    ByteArrayInputStream inStream = new
    ByteArrayInputStream(xmlStr.getBytes());
    DOMParser parser = new DOMParser();
    parser.setPreserveWhitespace(false);
    parser.parse(inStream);
    return parser.getDocument();

    How do you get the XML document? Do you use XSU? You can use:
    String str = qry.getXMLString();
    to get the result XML document in String.
    XSU will escape all of the < and >. Or the the XML document in
    one of the column will make the result XML doc not well-formed.
    Not quite understand your problem. You can send me your test
    case.
    i have an application that needs to send an XML document
    over the wire. For this reason, I need to convert the
    doc into a String at the sending side and back to Doc
    at the receiving side. This document is stored in a "CLOB"
    column in a table in the database. I use XDK to retrieve
    this entire row (including the CLOB - hence this is an XML
    document which has a column that itself is an xml document in
    string format - this is just the clob read in by XDK).
    Thus the row looks like
    <ROWSET>
    <ROW>
    <col1> A <col1>
    <CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
    </ROW>
    </ROWSET>
    When I convert this document into String and back, one of the "<"
    tags in the clob column document gets changed to "<" and hence
    the parsing fails! I have used the latest label of the XDK build
    to get the latest parser jar but still i have the same problem.
    I am using the following routines for the conversion.
    /* for converting document to string */
    public static String convertToString(XMLDocument xml) throws
    IOException
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    xml.print(pw);
    String result = sw.toString();
    return result;
    /* for converting string to document */
    public static XMLDocument convertToXml(String xmlStr)
    throws
    IOException,SAXException
    ByteArrayInputStream inStream = new
    ByteArrayInputStream(xmlStr.getBytes());
    DOMParser parser = new DOMParser();
    parser.setPreserveWhitespace(false);
    parser.parse(inStream);
    return parser.getDocument();

  • How to convert XML doc to string and vice versa?

    Assume I have a XML doc and I want to convert it into a string (and put it into a string variable).
    How can I do this?
    How can I do the opposite: Convert a string content into a XML doc?
    Peter

    Use:
    ParseEscapedXML() and ora:getContentAsString()
    See
    http://www.codeguru.com/cpp/sample_chapter/article.php/c10789__7/
    Marc

  • Function Module to convert multiple records into single record and vice-ver

    hi,
    i have a requirement to convert 10 records in an internal table to single record which should be passed
    to a single variable and store in the database.Kindly let me know is there any function module
    which meets my requirement. Also i need to do split one single record to 10 records each of
    say 65 length interval.
    kindly provide me if there is nay functinon module as such.
    I can do with ABAP-OOPS.Please suggest function module.

    I dont think such FM exists, but if you wanna code one it would be simple. Just loop through the internal table, keep concatenating the currently processing record into a long character variable to convert 10 records into one record.

  • Converting from String to float and vice versa

    I'm interested in people's thoughts on where common logic to convert between various field types should be stored in an application to minimise code duplication and maintenance.
    I have an application which consists of an object and a jPanel which displays and maintains this object. The object contains a number of private float fields which are accessed by getters and setters. The jPanel contains one jTextField for each of the fields within the object.
    Currently I have numerous lines of code in the jPanel to convert between the values needed by the getters and setters in the object (i.e. float) and the String value used by the jTextFields. This code handles cases where the String value may be blank or null.
    I've thought that one alternative to having all this conversion/validation code in the jPanel is to create a second set of getters and setters for each field which accept and return String values.
    What do people think about this? Is it advisable for only have one getter and setter for a variable? Should I put the conversion/validation logic for each field into a seperate common routine?
    Thanks,
    James.

    Hi James,
    You should go with whatever works best for you. By creating multiple getters and setter you save yourself from repeating the same code throughout your program.

  • I can't use my iPad for messages. When I tap the message icon it goes back to home screen and vice vers to send when the messages stays up

    I can't use my message on the iPad when I touch the icon it goes right back to home screen. And if I use from contacts and I hit the upper left hand writing implement it goes back to home screen.

      Try to Reset your device: 
    Press and hold both the Sleep/Wake button and the Home button for at least ten seconds, until the Apple logo appears (ignore the Slide to Power Off option that shows up first).

  • TS1868 My yahoo e mail account on my yahoo is sometimes missing messages sent from my mac or ipad and vice vers

    My yahoo mail account on yahoo is not synchronize with my yahoo mail set up on my mac air and ipad

    I really doubt that this has anything to do with Firefox. You say your are trying to use Yahoo Email, Firefox has nothing to do with that other than it displays the site for you.
    If you are having problems with Yahoo Email, I suggest you go to the Yahoo Email page and look for a Help or Support link and go there and see what you can find.
    Stan

  • Left sound in right ear and vice vers

    And yeah I have my headset put on the right way!!I had this problem for a long time, but tought at first it was the headset, but recently I had to purchase a new one, because the other one got old and the wire snaped. So I plugged the new headset to see if the problem was resolve, to my deception it was not!! ;(If anyone could help me with this I would realy appreciate it.Message Edited by Verident on 04-08-2005 02:34 PM

    Hey MAN! THX YOU
    I'm a computer tech! myself, and I feel dumb to admit I never tought about that:smileyvery-happy:. Well it work great now, but I would realy like to find a way to fix my front panel for easier access.
    Thx again
    Eric

  • How to convert from UNICODE (UTF16) to UTF8 and vice-versa in JAVA.

    Hi
    I want to insert a string in format UTF16 to the database. How do I convert from UTF16 to UTF8 and vice- versa in JAVA?. What type must the database field be? Do I need a special set up for the database (oracle 8.i)?
    thanks
    null

    I'm not sure if this is the correct topic, but we are having problems accessing our Japanese data stored in UTF-8 in our Oracle database using the JDBC thin driver. The data is submitted and extracted correctly using ODBC drivers, but inspection of the same data retrieved from the GetString() call using the JDBC thin driver shows frequent occurrences of bytes like "FF", which are not expected in either UTF8 or UCS2. My understanding is that accessing UTF8 in Java should involve NO NLS translation, since we are simply going from one Unicode encoding to another.
    We are using Oracle version 8.0.4.
    Can you tell me what we are doing wrong?
    null

  • My Mac Pro recently puts a 2008 date on calender and asking for web key code.  Why is this?

    Why is my Mac Pro 5 constantl putting a 2008 date on the calender and occasionally asking my key code?  I wiped computer clean and started fresh, but it is still doing this.   Any ideas? 

    Thanks for responding...
    It's a:
      MacBookPro5,5
      Processor Name: Intel Core 2 Duo
      Processor Speed: 2.26 GHz
    In addition when I reinstalled with the Mac OS X install DVD, I somehow lost IPHOTO.  I had backed up documents and pictures...but the pictures are on the desktop in 'library'.

  • Help needed XML to Internal table and vice versa

    Hello frnds, I need to convert Internal table to XML and Vice versa.
    Now I am able to most of the part except for this...
    the xml which I have to generate looks something like this...
    - <trade_dt>
    - <![CDATA[ 20111108000000:20111108235959
      ]]>
      </trade_dt>
    its a range I think
    And then the reponse which I get back the XML is like
    - <lockinfo>
    - <![CDATA[
    TRD_HEADER     1045     1          2
    ACT_CASHFLOW     1042               1
    TRD_TERM     1045               2
      ]]>
      </lockinfo>
    Is there any provision in class cl_ixml or class if_ixml_element to handle this part.....
    Edited by: Amit Sawant on Dec 28, 2011 3:51 PM

    Hello Amit,
    I would suggest you, to use the XSL-Transformations, which can be inbound used in ABAP.
    For example:
    DATA:
      l_xml       TYPE string,
      lt_flights  TYPE TABLE OF SFLIGHT.
    SELECT * FROM SFLIGHT INTO TABLE LT_FLIGHT.
    CALL TRANSFORMATION id
      SOURCE DATA = lt_flights
      RESULT XML l_xml.
    Now, you have a XML-String which is in the ABAP-XML Notation, which means, that ABAP can move this XML-Data back into an internal table/structure.
    For the backward, you have to use the following statement:
    CALL TRANSFORMATION id
      SOURCE XML l_xml
      RESULT DATA = lt_flights.
    As you will see, it is very easy. The Transformation "id" is just one example and build in. When you have to transform the data, or do not want to have the ASX-Notation in it, you should at least define your own transformations with the transaction XSLT_TOOL and use it similar to the transformation "id".
    Kind Regards,
    Hendrik

  • Can I convert .pdf documents to word and back again using Acrobat 9 Standard?

    Can I convert .pdf documents to word and vice versa using my (already purchased) Acrobat 9 Standard?
    OR do I need to inhstead upgrade the Acrobat 11 already on my laptop to PRO?

    See http://www.adobe.com/mena_en/products/acrobat/product-comparison.html
    The link is for Acrobat XI, but should basically be the same for Acrobat 9.
    [topic moved from Reader to Acrobat forum]

  • How to get the particular date information in calender???

    Hi Experts,
    I am using date navigator of type calender month view, now i want to get the information of the particular date in the calender and bind that data to the tooltip.
    I am able to get the information of the dates in the calender and i am setting it to the one context attribute. Now where should i bind the context attribute in my application.
    Can anyone please help how to do that????
    Regards,
    Anil

    Hi Jun,Nimisha,
    Thanks for the reply.
    In my appliation i am using the date navigator UI element which of type calender month view.
    once user moves cursor on to the any of the date in the calender i have to display the pointed date information.
    I have achieved it by created context attribute and i have binded it to the datemarkingelement tooltip.

Maybe you are looking for

  • How to adjust screen font for ipone 3GS

    My font on my iphone 3gs just went to about font size 36. How do I get it back to normal size?

  • Port Forwarding with Port Translation RV042, RV016, RV082

    This is a feature request for the Linksys RV series Routers.  Currently, it appears that the Cisco/Linksys RV042, RV082, and RV016 only support port forwarding and 1-to-1 Nat.  One item that I find very helpful with customers is port forwarding with

  • Trouble updating fresh install of CS5.0 on Mac

    Hi, I am in a corporate environment with CLP licenses of Adobe Creative Suite Design Premium CS5.0. Because we use some very expensive plugins, along with InDesign Server, and are connected to a database publishing program, there are a lot of depende

  • DVD doesnt work

    Hi I have the Presario  CQ 62-219 WM   My DVD  has not  worked  since I got it as a gift, because  Prior owner  could not  get it to work either. i have uninstalled  driver re booted  windows reinstalled driver  still no luck,  any help is Appreciate

  • Bug en important du texte dans indesign.

    Bonjour, Je travaille sur indesign CS5.5 et en important du texte d'Open Office ou Pages, le "i" devant le "l" ou devant le "n" forment des caractères étranges. Est-ce que cela parle à quelqu'un? Que faut-il faire? Merci de votre aide.