Date Problem-adding 30days to the date in string format.

hi i have an Date in the form of String "yyyy-mm-dd",i have to add 30 days to that date and compare it with to days date,i try to convert the string in to date format using SimpleDateFormat,but i could not understand how to add 30 days to that.pl it's an urgent problem,any help would be appreciated.
Regards.

to compare the date to todays date,
Calendar todaysDate = Calendar.getInstance();
todaysDate.after(cal2);
todaysDate.before(cal2);
Depending on which way you want to know.
To get the String Format I would suggest something like :
String dateInString = "" + cal2.get(Calendar.YEAR) + "-" + cal2.get(Calendar.MONTH) + "-" + cal2.get(Calendar.DATE);
Be careful though as this may give a format YYYY-M-D if the month or date is a single digit, so you may have to test string.length and then have "0"+cal2.get(Calendar.MONTH) /cal2.get(Calendar.DATE)
Hope this is of some help.

Similar Messages

  • I upgraded to Mountain from Snow and find that there is now a problem adding iphoto to the cloud.  I have iphoto '08,version 7.1.5.  Tried to follow one poster's advice and upgrade to 9.1 but I need 9.0 first and I can't find that.  suggestions? thanks!

    I upgraded to Mountain from Snow and find that there is now a problem adding iphoto to the cloud.  I have iphoto '08,version 7.1.5.  Tried to follow one poster's advice and upgrade to 9.1 but I need 9.0 first and I can't find that.  suggestions? thanks!

    You have to buy iPhoto from the Mac App Store.

  • How to convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • Convert a date in String format to a Date

    Hi,
    How can I convert a date in String format to a Date object?
    I have tried:
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Locale;
    import java.sql.*;
    public class casa {
    public static Connection con = null;
    public static Statement s = null;
    public static String sql = null;
    public static String mydate = "01.01.2001";
    /** Creates a new instance of casa */
    public casa() {
    public static void main(String[] args) throws SQLException{
    try {
    DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    Date date = shortFormat.parse(mydate);
    //Open Database
    con = getConnection();
    s = con.createStatement();
    sql = "select date1 from table1 where date1 <= '"+date+"'";
    ResultSet rs = s.executeQuery(sql);
    while(rs.next()){
    String aba = rs.getString("datum");
    System.out.println("New Datum = "+aba);
    } catch (Exception ex ) {
    ex.printStackTrace();
    closeConnection(s, con);
    //Connection
    private static Connection getConnection() {
    Connection con = null;
    String user ="aouzi";
    String passe ="aouzi";
    String url = "jdbc:db2:EjbTest";
    try {
    //Datenbanktreiber laden
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    //Verbindung herstellen
    con = DriverManager.getConnection(url,user,passe);
    }catch(ClassNotFoundException e){
    } catch(SQLException e){}
    return con;
    //close Connection
    private static void closeConnection(Statement s, Connection con) {
    try {
    s.close();
    } catch (SQLException e) {}
    try {
    con.close();
    } catch (SQLException e) {}
    I'm getting the following errors:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0180N
    The syntax of the representation of a date/time of day value as character sequence is false. .SQLSTATE=22007

    I'm pretty sure it won't understand what date.toString() returns. If you know what format the database understands, you do it like this:
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy"); // e.g. 18-Apr-02
    String datestring = sdf.parse(date);
    and use that instead of date in your sql string. Some databases understands it if you do
    "to_date('18-Apr-02')"
    so you could include that in your sql string as well..
    You could also try to make it a java.sql.Date and hope your jdbc driver knows how to convert it to a string that the database understands if you don't know the format:
    con = getConnection();
    PreparedStatement ps = con.prepareStatement("select date1 from table1 where date1 <= ?");
    ps.setDate(new java.sql.Date(date.getTime()));
    ResultSet rs = s.executeQuery(sql);

  • PodCast: problem adding photos to the Podcast Track!

    Hi all,
    I was just making my 1st podcast when I encountered a strange problem: I wanted to drag&drop photos from the media browser but not all of them worked!
    Some photos could be dropped without a problem (instatntly visible by the green + ball sticking to the mouse pointer) while with others this green + icon doesn't appear and the photo won't drop into the Podcast Track.
    I consulted the GB Help but to no avail.
    However, I observed the following: all my photos in portrait format work and all my photos in landscape format don't work.
    The photos are taken with my DSLR camera and have a resolution of 3008x2000 pixel.
    So, together with the portrait/landscape observation: could it be that 2000 pixel by 2000 pixel is the max size of a photo so that it can be dropped onto the Podcast Track?
    A double click on a photo in the media browser doesn't open GB's own little photo editor (opposed to when you double click on a photo in the markers track list) so one can't crop the photos within GB.
    So, do I need to crop the landscape 3008x2000 images in iPhoto (or any other sim. app.) first?
    Any comments?
    Thanks a lot & cheers from Germany,
    Stefan.

    Hey Stefan,
    A couple of potential issues here. First off you may be right that there's some type of file size limit issue, either because there's a max filesize built-in, or because since you're able to "scale" your photos for display within the chapter/markers area, maybe GB wants a file it knows it can work with reasonably.
    Secondly, I'd be wary of putting lots of large photos in your cast, as that may contribute to giant file sizes on export. The one thing you might want to test is to see what GB does with the photos when you've selected the Preferences>Export>Set Artwork to recommended size for Podcasts check box.
    Or maybe try unchecking that box (if you have it checked now) and then see if a big photo can then be brought in.
    What I've been doing with large photos is exporting them from iPhoto at a smaller scale, then importing them into a new album, or in the case of images from the web, just adding them to iPhoto and scaling them in GB in the chapter markers area. I also use Photoshop to "pre-scale" but I wouldn't think it was necessary just for a Podcast.
    Hopefully this helps.

  • How can i convert if the date in string format

    String lFstr = (String) pReq.getParameter("FND");
    String lTstr = (String) pReq.getParameter("TND");
    String lLstr = (String) pReq.getParameter("LWD");
    System.out.println(lFstr + " " + lTstr + " " + lLstr);
    //DateFormat ds = DateFormat.getDateInstance();
    DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
    Date lFdate = null;
    Date lTdate = null;
    Date lLdate = null;
    try {
    lFdate = dateFormatter.parse(lFstr);
    lTdate = dateFormatter.parse(lTstr);
    lLdate = dateFormatter.parse(lLstr);
    } catch (Exception e) {
    System.out.println(lFdate+" "+lTdate+" "+lLdate);
    i am getting the values from request parameters at that time it is giving values.
    after convertion of string to date it is giving the null value what is wrong in this code

    It might have thrown an exception. Try printing the stack trace in the catch block.

  • Problem adding contacts to the contact list in PSE7

    I am running PSE 7 with Windows 7. I had a similar problem last February http://forums.adobe.com/thread/581476?tstart=0 trying to update the contact list. The only difference last year is a different PC and I was running XP.
    I am running into the same problem today. In summary I could enter contacts manually or import via Outlook but once I closed the contact list and reopened nothing was updated. I followed all the instructions in John Ellis’s response http://forums.adobe.com/message/2583020#2583020 but it is not working this time. I am not logged into photoshop.com. I saw a link where this fixed someone else who was having a similar problem.
    I have my preferences set to Microsoft Outlook. I am using Outlook 2003.
    Does anyone have an idea what I should try next.

    Yesterday I posted this thread. After I convinced my self that I was properly following the directions given by John Ellis I needed to start elsewhere to resolve the problem.
    What I did was found my contacts.xml file and moved it to my documents folder. I then went back to the organizer and attempted to load the additional contacts expecting the contacts folder to be empty. It was not. I loaded the new contacts using the vcard/desktop method per John’s thread. Now everything is updating and an updated contact folder is in the original location.
    Can anyone explain how the new contact folder acquired all the original contacts?

  • Problem Adding Tree Node the second time around.

    I got a tree and a fixed parent nodes of my dynamic childs.
    It works fine during the first call but not on the successive calls.
    This code is called via popup many times as the user wish ...
    // nodelabels is the default parent.
    DefaultMutableTreeNode x = new DefaultMutableTreeNode("My New Node");
    nodelabels.add(x);
    Please help I am stuck with this thing.
    Thanks and Advance.

    you should post the model you use for the tree (if you use one)...

  • How to read date as string (format dd-mm-yyyy) and store it as Date object

    Hi. I would like to read from keyboard String with a date and put this value to Date object. How can i do this???
    Thanks

    Check out java.text.SimpleDateFormat.
    Basically
    String dateString = readUserInput(); // get the string
    SimpleDateFormat myFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date myDate = myFormat.parse(dateString);

  • Convert the date of string to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.

    I need convert the date of string format 'MM/dd/yyyy' to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.Since
    I need to search values based on date where my database datetime  is 'MM/dd/yyyy' format.

    In my opinion you should re-consider the assumption that the date picker returns a string. Maybe it is able to return a
    DateTime object directly instead of string. Then you will pass this value as a parameter of SQL query. This should work regardless of computer configuration.
    Otherwise, follow the previous string-based approaches.

  • How to Get Blob data(In String Form) using OCCI

    Hello frnds,
    I am new to OCCI,so i hvnt that much of master in that side.
    I have one problem while handling BLOb data.
    How to convert binary form of SDO_GEOMETRY data into string format. I am able to convert data by using PLSQL block,but its take so much time to execute.So performance is the main issue.So if there is any API in OCCI which convert directly blob data into string format.
    Thanx in advance for your support,
    Nilesh.

    Have you tried reading "http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/lobs.htm#BABDEGJD" ? This explains how you can read from BLOBs into a C vector (or C++ vector of chars).

  • Convert date in sql format

    how to convert a date in string format to sql date format?
    thanx in advance

    Use java.text.SimpleDateFormat to parse the String into a java.util.Date.
    Create a java.sql.Date from the java.util.Date.
    Use a PreparedStatement and its setDate() method to set the date in the SQL. The JDBC driver will take care of putting that java.sql.Date object into the correct format for your DB.

  • Problem in getting last value of a string in Function Module

    Hi,
    I am working on FM in which i have to put highfen mark which is working ok,but the problem if there is when the value of string finds a space it should not insert highfen in it and i am not able to put the condition in it as it showing the higfen even when the word is full in the first line.i want to show highfen where the word is not able to display complete. here is d code which i am using right now. plzz provide me guidlines to solve this problem.
    here's d code:-
    FUNCTION Z_STRING_LENGTH1.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_STRING) TYPE  STRING
    *"     VALUE(LENGTH) TYPE  I
    *"  EXPORTING
    *"     VALUE(E_STRING) TYPE  STRING
    data: STRING_F type string, "Stores the value in string format
          STRING_LENGTH type i, "Length of the string
          DIFF type i,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 type string,  "Stores the 1st String
          STRING2 type string,  "Stores the 2nd String
          STRING3 type string,  "Stores the 3rd String
          STRING4 type string,  "Stores the 3rd String
          STRING5 type string,  "Stores the 3rd String
          LENGTH2 type I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING2 = STRING_F+LENGTH(DIFF).
    ELSE.
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    length2 = length - 1.
    STRING3 = STRING1+length2(1).
    STRING4 = STRING2+0(1).
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      concatenate STRING1 '-' STRING2  into STRING5.
      e_string = STRING5.
    ELSE.
      concatenate  STRING1 STRING2 into STRING5.
      e_string = STRING5.
    ENDIF.
    ENDFUNCTION.
    Edited by: ricx .s on May 12, 2009 5:20 AM

    Hi,
    I checked your code... its working fine except for some cases it is giving dumps for which I have added certain if conditions....
    Please check the modified code below... have optimized it as well by removing one extra if condition....
    you can copy and paste the code below...
    DATA: STRING_F TYPE STRING, "Stores the value in string format
          STRING_LENGTH TYPE I, "Length of the string
          DIFF TYPE I,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 TYPE STRING,  "Stores the 1st String
          STRING2 TYPE STRING,  "Stores the 2nd String
          STRING3 TYPE STRING,  "Stores the 3rd String
          STRING4 TYPE STRING,  "Stores the 3rd String
          STRING5 TYPE STRING,  "Stores the 3rd String
          LENGTH2 TYPE I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
      STRING2 = STRING_F+LENGTH(DIFF). " added this statement in this if itself instead of one extra if
    " which is not required
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    IF LENGTH IS NOT INITIAL.
      LENGTH2 = LENGTH - 1.
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value as 0
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 0, then it gives me a dump
    STRING3 = STRING1+LENGTH2(1).
    IF STRING2 IS NOT INITIAL.
      STRING4 = STRING2+0(1).
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value greater than or equal to
    " the string length
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 8, then it gives me a dump
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      CONCATENATE STRING1 '-' STRING2  INTO STRING5.
      E_STRING = STRING5.
    ELSE.
      CONCATENATE  STRING1 STRING2 INTO STRING5.
      E_STRING = STRING5.
    ENDIF.

  • When I drag music from a folder that contains songs by different artists and then sort by date added it shows the songs in alphabetical order by artist?

    When I drag a bunch of songs with different artists from a folder on my computer to the itunes library and sort by Date added it puts them into alphabetical order by artist. I am able to workaround this by using date modified. Why does itunes do this? This started happening in July. Prior to that never had this problem. Been adding my music the same way for almost a decade.

    They are added in the same minute. I do not see the second area next to that if it should be. I'm guessing an update to a newer itunes build is responsible. It's a shame. I am using the sort by date modified. But now whenever I modify a file in Itunes it automatically moves it to the top of the list. I am trying to keep the newest stuff at the top of my itunes.

  • Problems adding Bridge Data to prepaid (Allset) iPhone5

    Anyone having problems trying to add bridge data to a prepaid (Allset) phone. I've tried to add 3GB to my iPhone 5 all day today and I've had no success. I've tried doing through (1) the new My Verizon Mobile App, (2) dialing *611 and following the prompts and (3) on my PC while logged into my "My Verizon" account. All three methods result in a "system error" and I can't add any bridge data. The only thing that worked, was it allowed me to put $25 on account by charging my credit card. So now I've been taken for $25 and can't do anything with the money on now have in my account. A call to customer service was a complete waste of time. The CSR told me to do the *228 Activation code on my 4G LTE iPhone 5. I'm not a CSR and I know you don't use *228 on an a 4G iPhone! After wasting 30 minutes and being told my SIM card "had to age" (very creative), I got tired of the snow job and hung up. Is anyone else having problems adding bridge data? Please advise if you have succeeded in adding bridge data today.

    Why have a Prepaid forum that is not monitored by CSR's who can actually do something about the issues posted by Prepaid customers? I'm not looking for a "sorry to hear about your problem" reply, I'm looking for answers/solutions. 
    What a ridiculous arrangement. This Prepaid sub-forum should be deleted so customers don't waste their time posting problems here.
    Sent from my iPad

Maybe you are looking for