Convert system date into mm-dd-yyyy format

Hi everyone, I am developing an web application in jsp.In my application when a client enters his information like name,email etc, they are copied into the database.What i need now is at the same time the system date also has to enter into the database in the format mm-dd-yyyy.My application doesn't ask the user to enter the particular date.So immediately after the client clicks the save button along with the information he saved the system date also has to enter into his particular database. Can anyone help me how to program this or give an idea regarding the approach to be followed. Any sample code is highly appreciated.Thanks in advance,

well, your application collects user entered info at some place (either in a jsp or a servlet or a handler). At this point you have to generate the sysdate in the specified format.
For example, if its a servlet that collects the user info,
public void doGet(.........){
   //collect all request parameters
   //code from previous post to generate date in specific format
   //call method to insert all data
}You will have to import the library classes as shown below in your program.
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;cheers,
ram.
PS: Also when your sql statement should use some kind of functions to convert the String to a date value for insertion.
For example, in Oracle, you would do this,
insert into test values(to_date('08-24-2005','mm-dd-yyyy'));Here test is a table with one date column.
The to_date() function converts the string, which is the first argument, to a date and conversion pattern is the second argument.
Unfortunately I cant help you with this because Iam not so familiar with mysql.
cheers,
ram.

Similar Messages

  • How to convert system Date into DD-MMM-YYYY Format

    hi friends,
    please help me How to convert system Date into DD-MMM-YYYY Format.
    Regards
    Yogesh

    HI..
    data: w_dt(11) type c,
             w_month(2),
             w_mon(3).
    w_month = p_date+4(2). **p_date = given date**
    case w_month.
    when '01'.
    w_mon = 'Jan'.
    when '02'.
    w_mon = 'Feb'.
    when '03'.
    w_mon = 'Mar'.
    when '04'.
    w_mon = 'Apr'.
    when '05'.
    w_mon = 'May'.
    when '06'.
    w_mon = 'Jun'.
    when '07'.
    w_mon = 'Jul'.
    when '08'.
    w_mon = 'Aug'.
    when '09'.
    w_mon = 'Sep'.
    when '10'.
    w_mon = 'Oct'.
    when '11'.
    w_mon = 'Nov'.
    when '12'.
    w_mon = 'Dec'.
    endcase.
    Now...
      concatenate p_date6(2)  '-'  w_mon  '-'   p_date0(4)  into w_dt.
    write w_dt.

  • How to convert date  into dd mon yyyy format

    hi all,
    i have a problem in date format i am using date like below .
    <%java.util.Date date = new java.util.Date();%>
    i am inserting date into a table and its storing like this
    insert into tablename (d_date) values (date)
    and its inserting date like below
    Sun Oct 19 09:05:45 GMT+03:00 2003
    i want to fetch date in dd mon yyyy format.
    with this format i want to make a select query.i struck with the format conversion.
    how to do this.
    any comments please.
    any help

    hi all,
    i understand now where i am wrong.
    the below code is not working why because in my server where i am executing code the regional setting month value is in arabic.
    i executed the same code in a different server where date and time jones are english its working fine.
    All the problem is in regional setting and not the jsp code.
    <%
    String whtEverDateFormatYouWAnt = "dd MMM yy";
    String str = new SimpleDateFormat(whtEverDateFormatYouWAnt).format(new SimpleDateFormat("EEE MMM dd HH:mm:ss vvv yyyy").parse("Sun Oct 19 09:05:45 GMT+03:00 2003"));
    out.print(str);
    %>
    Thanks a lot for the excellent solution.
    Thanks again.

  • Convert system date to MM/dd/yyyy

    Hi,
    I have to insert system date(current date) to MS Access database which contains colums in MM/dd/yyyy. Can you tell me how can i do it?
    --Ramesh.N                                                                                                                                                                                                                                                                                                                           

    String getDate() {
              Date theDate = new Date();
              SimpleDateFormat newForm = new SimpleDateFormat("MM/dd/yyyy");
              String date =  newForm.format(theDate);
              return date;
         }Try that

  • Converting string to date in mm/dd/yyyy format

    Hi,
    I used simpledateformat to convert date to "MM/dd/yyyy" format.
    Now when i want to insert into db, i want the value as date object instead of string [returned by format method of SimpleDateFormat]
    what should i do?
    Date dt = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    System.out.println("Formatted date is coming as "+sdf.format(dt));
    Date dt1 = sdf.parse(sdf.format(dt);
    System.out.println("parsed date is coming as " +dt1);
    output :
    1 SOP returns 11/07/2007 [current date]
    2 SOP returns Wed Nov 07 00:00:00 GMT+05:30 2007

    If you are using PreparedStatements setDate method, you need a java.sql.Date object, not a Java.util.Date object. You can create an sql.Date object from a util.Date object as follows:
    java.sql.Date sqlDate = new java.sql.Date(dt.getTime());And, if you are not using PreparedStatement and its setDate method, then change now.
    Doing
    Date dt1 = sdf.parse(sdf.format(dt));is meaningless. You format the date to string, then parse the string back to a date? Why? Why not just use the original Date object? And you won't get a sql.Date object that way, either, as the DateFormat classes return a util.Date object.
    Edit: And for more info:
    A Date does not have a format. It is simply a number. The "format" only comes into play when printing the String representation of the Date, and that is not handled by the Date object itself (except when calling toString either explicitly or implicitly).

  • Convert the date into user default date formate

    I am wrinting a bdc and i want to convert the date into user default date farmate ..please suggust the functiom module should i use...

    actually by using dats or d type you can get the user specific date itself.
    but if u have different dates format that need to be converted to the user specific date then you can follow below procedure
    1. retrieve the user format from usr01
        SELECT SINGLE datfm
          INTO w_datfm
          FROM usr01
         WHERE bname EQ sy-uname.
    pass w_datfm to the below FM (4th import parameter)
    2. create Z - FM and retrieve the user secific date
    FUNCTION ZFXX_USER_SPECIFIC_DATE.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(IW_DAY) TYPE  CHAR2
    *"     VALUE(IW_MONTH) TYPE  CHAR2
    *"     VALUE(IW_YEAR) TYPE  CHAR4
    *"     VALUE(IW_DATFM) TYPE  USR01-DATFM
    *"  EXPORTING
    *"     VALUE(EW_USER_DATE) TYPE  CHAR0008
    *1  DD.MM.YYYY
    *2  MM/DD/YYYY
    *3  MM-DD-YYYY
    *4  YYYY.MM.DD
    *5  YYYY/MM/DD
    *6  YYYY-MM-DD
    CASE iw_datfm.
      when '1'.
        concatenate iw_day iw_month iw_year
               into ew_user_date.
      when '2'.
        concatenate iw_month iw_day iw_year
               into ew_user_date.
      when '3'.
        concatenate iw_month iw_day iw_year
               into ew_user_date.
      when '4'.
        concatenate iw_year iw_month iw_day
               into ew_user_date.
      when '5'.
        concatenate iw_year iw_month iw_day
               into ew_user_date.
      when '6'.
        concatenate iw_year iw_month iw_day
               into ew_user_date.
      when others.
        clear ew_user_date.
    endcase.
    ENDFUNCTION.

  • 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 java.sql.date to dd.mm.yyyy format

    Hi,
    Can any one tell me how to convert java.sql.date to dd.mm.yyyy format
    Regards,
    H.V.Swathi

    Hi ,
    Create a simple data type of type java.sql.date and give the format in it as "dd/MM/yyyy". This will work i guess.
    Regards
    Ishita

  • Convert system time into User local time.

    Hi,
    How to convert System time into User Local time.
    Are there any FMs available.
    Regards,
    Kiran

    hi,
    There is just one simple funda behind the Date and time logic in SAP.
    -> It is absolutely useless to store Date and time directly in DB. Why ?
    Because 00:00 a.m in London could mean 05:30 in India !! So If I (in India) store a Date 1st Feb 2008 , 10:00 a.m .. This time for a person in London could be invalid.. because he is behind your time zone..
    So the solution is to store the date/times in Timestamps format. Taking the above example.. 1st Feb 2008, 10:00 a.m (in India) will be stored as 20080201043000.
    This time if seen in German Time zone will look as : 1st Feb 2008, 05:30 a.m.
    Simple right
    -> In India we store date as DD.MM.YYYY while in other countries they store it as MM.DD.YYYY.
    The separator could be . or - or / .
    The date format is user dependent. I might prefer to store it as DD.MM.YYYY and you might want to store it as MM-DD-YYYY.
    System does not bother what your format is. It always stores in YYYYMMDD (8 Char)
    On screens if you want to display Date then it must always be shown in that users format who is seeing it. How to get this done ?
    DATA : lv_date(10) type c.
    write sy-datum into lv_date.
    So in LV_DATE variable the date will be stores in the users format.
    Simple right
    There are function modules that do the same. But normally we should avoid use of FM to make code simpler, short and easy... no complications at all ..
    You can use system variables sy-datlo (Local Date for Current User) and sy-timlo ( Local Time of Current User ).
    You can also use GET TIME statement.
    reward if useful,
    preet

  • Insertion of date in dd-mmm-yyyy format

    I have a jsp page, from that i can enter values in oracle database.
    my jsp page is working, but the problem is that it can only accept the date
    dd-mmm-yyyy format. i.e 20-jun-2004, but when i enter date in dd/mm/yyyy format i.e 20/06/2004, it does not accept.
    i want to enter to do enter date in dd/mm/yyyy format in the form, and it can save the date field in database in dd-mmm-yyyy format.
    my code is as bellow:
    <html>
    <body>
    <table>
    <tr>
    <td>
    <%@ page import =" java.sql.Date.*" %>
    <%@ page import =" java.text.SimpleDateFormat.*" %>
    <%@ page import =" java.util.Date.*" %>
    <%@ page import =" java.text.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page language="java" import="java.sql.*" %>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection("jdbc:odbc:pf","scott","ttlscott");
    System.out.println("got connection");
    %>
    <%
    char pay_post,pay_type;
    String action = request.getParameter("action");
    if (action != null && action.equals("save")) {
    conn.setAutoCommit(false);
    PreparedStatement pstmt = conn.prepareStatement(
    ("INSERT INTO pay_header VALUES (?, ?, ?, ?, ?, ?,?,?)"));
    pstmt.setString(1,request.getParameter("vou_no"));
    pstmt.setString(2,request.getParameter("pay_date"));
    pstmt.setString(3,request.getParameter("pay_post"));
    pstmt.setString(4,request.getParameter("pay_narr"));
    pstmt.setString(5, request.getParameter("chq_no"));
    pstmt.setString(6,request.getParameter("chq_date"));
    pstmt.setFloat(7,Float.parseFloat(request.getParameter("chq_amt")));
    pstmt.setString(8,request.getParameter("pay_type"));
    pstmt.executeUpdate();
    conn.commit();
    conn.setAutoCommit(true);
    %>
    <%
    Statement statement = conn.createStatement();
    ResultSet rs = statement.executeQuery
    ("SELECT * FROM pay_header ");
    %>
    <tr>
    <form action="payment_save1.jsp" method="get">
    <input type="hidden" value="save" name="action">
    <th><input value="" name="vou_no" size="10"></th>
    <th><input value="" name="pay_date" size="10"></th>
    <th><input value="" name="pay_post" size="15"></th>
    <th><input value="" name="pay_narr" size="15"></th>
    <th><input value="" name="chq_no" size="15"></th>
    <th><input value="" name="chq_date" size="15"></th>
    <th><input value="" name="chq_amt" size="15"></th>]
    <th><input value="" name="pay_type" size="15"></th>
    <th><input type="submit" value="save"></th>
    </form>
    </tr>
    <%
    while ( rs.next() ) {
    %>
    <tr>
    <form action="payment_save1.jsp" method="get">
    <input type="hidden" value="save" name="action">
    <td><input value="<%= rs.getString("vou_no") %>" name="vou_no"></td>
    <td><input value="<%= rs.getDate("pay_date") %>" name="gl_descr"></td>
    <td><input value="<%= rs.getString("pay_post") %>" name="pay_post"></td>
    <td><input value="<%= rs.getString("pay_narr") %>" name="pay_narr"></td>
    <td><input value="<%= rs.getString("chq_no") %>" name="chq_no"></td>
    <td><input value="<%= rs.getDate("chq_date") %>" name="chq_date"></td>
    <td><input value="<%= rs.getFloat("chq_amt") %>" name="chq_amt"></td>
    <td><input value="<%= rs.getString("pay_type") %>" name="pay_type"></td>
    <td><input type="submit" value="save"></td>
    </form>
    </tr>
    <%
    %>
    </table>
    <%
    // Close the ResultSet
    rs.close();
    // Close the Statement
    statement.close();
    // Close the Connection
    conn.close();
    } catch (SQLException sqle) {
    out.println(sqle.getMessage());
    } catch (Exception e) {
    out.println(e.getMessage());
    %>
    </td>
    </tr>
    </body>
    </html>

    thanx for u r help..
    now i have used simple date format method and also apllied setDate() method.
    bit its coming error NULL
    code:
    SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
    java.util.Date pay_date_temp = null;
    java.util.Date pay_post_temp = null;
    PreparedStatement pstmt = conn.prepareStatement(
    ("INSERT INTO pay_header VALUES (?, ?, ?, ?, ?, ?,?,?)"));
    java.sql.Date pay_date = new java.sql.Date(pay_date_temp.getTime());
    java.sql.Date chq_date = new java.sql.Date(pay_post_temp.getTime());
    pstmt.setString(1,request.getParameter("vou_no"));
    pstmt.setDate(2,pay_date);
    pstmt.setString(3,request.getParameter("pay_post"));
    pstmt.setString(4,request.getParameter("pay_narr"));
    pstmt.setString(5, request.getParameter("chq_no"));
    pstmt.setDate(6,chq_date);
    pstmt.setFloat(7,Float.parseFloat(request.getParameter("chq_amt")));
    pstmt.setString(8,request.getParameter("pay_type"));
    help me

  • Insert date in dd-mmm-yyyy format

    I have a jsp page, from that i can enter values in oracle database.
    my jsp page is working, but the problem is that it can only accept the date
    dd-mmm-yyyy format. i.e 20-jun-2004, but when i enter date in dd/mm/yyyy format i.e 20/06/2004, it does not accept.
    i want to enter to do enter date in dd/mm/yyyy format in the form, and it can save the date field in database in dd-mmm-yyyy format.
    my code is as bellow:
    <html>
    <body>
    <table>
    <tr>
    <td>
    <%@ page import =" java.sql.Date.*" %>
    <%@ page import =" java.text.SimpleDateFormat.*" %>
    <%@ page import =" java.util.Date.*" %>
    <%@ page import =" java.text.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page language="java" import="java.sql.*" %>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection("jdbc:odbc:pf","scott","ttlscott");
    System.out.println("got connection");
    %>
    <%
    char pay_post,pay_type;
    String action = request.getParameter("action");
    if (action != null && action.equals("save")) {
    conn.setAutoCommit(false);
    PreparedStatement pstmt = conn.prepareStatement(
    ("INSERT INTO pay_header VALUES (?, ?, ?, ?, ?, ?,?,?)"));
    pstmt.setString(1,request.getParameter("vou_no"));
    pstmt.setString(2,request.getParameter("pay_date"));
    pstmt.setString(3,request.getParameter("pay_post"));
    pstmt.setString(4,request.getParameter("pay_narr"));
    pstmt.setString(5, request.getParameter("chq_no"));
    pstmt.setString(6,request.getParameter("chq_date"));
    pstmt.setFloat(7,Float.parseFloat(request.getParameter("chq_amt")));
    pstmt.setString(8,request.getParameter("pay_type"));
    pstmt.executeUpdate();
    conn.commit();
    conn.setAutoCommit(true);
    %>
    <%
    Statement statement = conn.createStatement();
    ResultSet rs = statement.executeQuery
    ("SELECT * FROM pay_header ");
    %>
    <tr>
    <form action="payment_save1.jsp" method="get">
    <input type="hidden" value="save" name="action">
    <th><input value="" name="vou_no" size="10"></th>
    <th><input value="" name="pay_date" size="10"></th>
    <th><input value="" name="pay_post" size="15"></th>
    <th><input value="" name="pay_narr" size="15"></th>
    <th><input value="" name="chq_no" size="15"></th>
    <th><input value="" name="chq_date" size="15"></th>
    <th><input value="" name="chq_amt" size="15"></th>]
    <th><input value="" name="pay_type" size="15"></th>
    <th><input type="submit" value="save"></th>
    </form>
    </tr>
    <%
    while ( rs.next() ) {
    %>
    <tr>
    <form action="payment_save1.jsp" method="get">
    <input type="hidden" value="save" name="action">
    <td><input value="<%= rs.getString("vou_no") %>" name="vou_no"></td>
    <td><input value="<%= rs.getDate("pay_date") %>" name="gl_descr"></td>
    <td><input value="<%= rs.getString("pay_post") %>" name="pay_post"></td>
    <td><input value="<%= rs.getString("pay_narr") %>" name="pay_narr"></td>
    <td><input value="<%= rs.getString("chq_no") %>" name="chq_no"></td>
    <td><input value="<%= rs.getDate("chq_date") %>" name="chq_date"></td>
    <td><input value="<%= rs.getFloat("chq_amt") %>" name="chq_amt"></td>
    <td><input value="<%= rs.getString("pay_type") %>" name="pay_type"></td>
    <td><input type="submit" value="save"></td>
    </form>
    </tr>
    <%
    %>
    </table>
    <%
    // Close the ResultSet
    rs.close();
    // Close the Statement
    statement.close();
    // Close the Connection
    conn.close();
    } catch (SQLException sqle) {
    out.println(sqle.getMessage());
    } catch (Exception e) {
    out.println(e.getMessage());
    %>
    </td>
    </tr>
    </body>
    </html>

    thanx for u r help..
    now i have used simple date format method and also apllied setDate() method.
    bit its coming error NULL
    code:
    SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
    java.util.Date pay_date_temp = null;
    java.util.Date pay_post_temp = null;
    PreparedStatement pstmt = conn.prepareStatement(
    ("INSERT INTO pay_header VALUES (?, ?, ?, ?, ?, ?,?,?)"));
    java.sql.Date pay_date = new java.sql.Date(pay_date_temp.getTime());
    java.sql.Date chq_date = new java.sql.Date(pay_post_temp.getTime());
    pstmt.setString(1,request.getParameter("vou_no"));
    pstmt.setDate(2,pay_date);
    pstmt.setString(3,request.getParameter("pay_post"));
    pstmt.setString(4,request.getParameter("pay_narr"));
    pstmt.setString(5, request.getParameter("chq_no"));
    pstmt.setDate(6,chq_date);
    pstmt.setFloat(7,Float.parseFloat(request.getParameter("chq_amt")));
    pstmt.setString(8,request.getParameter("pay_type"));
    help me

  • How to Insert date in 'DD/MM/YYYY' format in oracle using stored procedure?

    Hi
    How to Insert date in 'DD/MM/YYYY' format in oracle using stored procedure?
    This is my Input data.
    11/25/2007.
    By using below query, it is inserted into database.
    sql>Insert into tblname values(to_date('11/25/2007','MM/DD/YYYY'));
    But using stored procedure, the same query is not running.
    It shows error like
    ORA-01843: not a valid month ORA-06512: at line 1
    Procedure:
    create or replace procedure Date_Test(datejoin in DATE) is
    begin
    insert into datetest values(to_date(datejoin,'MM/DD/YYYY'));
    end Date_Test;
    I had used 'nls_date_language = american' also.
    Prcodeure is created but not worked in jsp. The same error is thrown.
    Pls provide a solution

    This might help you....
    SQL> Create Table DateTest(col1 Date);
    Table created.
    Elapsed: 00:00:00.00
    SQL> create or replace procedure Date_Test(datejoin in DATE) is
    2 begin
    3 insert into datetest values(to_date(datejoin,'MM/DD/YYYY'));
    4 end ;
    5 /
    Procedure created.
    Elapsed: 00:00:00.00
    SQL> exec Date_Test('11/25/2007');
    BEGIN Date_Test('11/25/2007'); END;
    ERROR at line 1:
    ORA-01843: not a valid month
    ORA-06512: at line 1
    Elapsed: 00:00:00.00
    SQL> exec Date_Test(To_Date('11/25/2007','mm/dd/yyyy'));
    BEGIN Date_Test(To_Date('11/25/2007','mm/dd/yyyy')); END;
    ERROR at line 1:
    ORA-01843: not a valid month
    ORA-06512: at "CTBATCH.DATE_TEST", line 3
    ORA-06512: at line 1
    Elapsed: 00:00:00.00
    SQL> create or replace procedure Date_Test(datejoin in DATE) is
    2 begin
    3 insert into datetest values(datejoin);
    4 end ;
    5 /
    Procedure created.
    Elapsed: 00:00:00.00
    SQL> exec Date_Test(To_Date('11/25/2007','mm/dd/yyyy'));
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL> Select * from DateTest;
    COL1
    25-NOV-07
    Elapsed: 00:00:00.00
    SQL> create or replace procedure Date_Test(datejoin in VarChar2) is
    2 begin
    3 insert into datetest values(to_date(datejoin,'mm/dd/yyyy'));
    4 end ;
    5 /
    Procedure created.
    Elapsed: 00:00:00.00
    SQL> exec Date_Test('11/25/2007');
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL> select * from DateTest;
    COL1
    25-NOV-07
    25-NOV-07
    Elapsed: 00:00:00.00
    SQL>

  • How can I get the system date in mm/dd/yyyy,

    how can I get the system date in mm/dd/yyyy, i need to compare system date with some other date,continuosly using threads,can U plz help me.
    With Some code
    Thanks In advnace
    Mahiiii

    Hi,
    You can use SimpleDateFormat class under java.text package.
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy h:mm a z", new Locale());
    //formatter.setTimeZone(timezone);
    String dateTime = formatter.format(new Date());

  • Date in mm/dd/yyyy format

    I have a dunning output that is prodcuing the date in mm/dd/yyyy format despite the user settings being dd/mm/yyyy - and there is no set country command on the form - any ideas of why this is occuring or how I change it.

    Hi,
    This can be because at time the date settings can be pulled from customer records.
    For example. In SPRO you can configure date settings based on countries.
    So if your customer belongs to XXXX country then it can pick up the date settings from SPRO.
    You can check with a functional guy for the node where you do settings for different countries.
    I will try and send you the details later as i dont have system handy.
    Thanks

  • Calculate future date in MM/dd/yyyy format

    Hi,
    I am trying to add a 56 months to a given date (MM/dd/yyyy string) and output the date in MM/dd/yyyy format.
    Here is my code:
                   SimpleDateFormat date = new SimpleDateFormat("MM/dd/yyyy");
                   date.parse("07/30/2000");
                   GregorianCalendar gc = new GregorianCalendar();
                   gc.add(Calendar.MONTH,+56);
                   System.out.println(date.format(gc.getTime()));  I tried to assign date.parse() to a Date but there is no fomat method on Date so to add months to the date. Could someone suggest me how to calculate a future date?

    thanks for looking, just found the answer:
                   SimpleDateFormat date = new SimpleDateFormat("MM/dd/yyyy");
                   Date dt = date.parse("07/30/2000");
                   GregorianCalendar gc = new GregorianCalendar();
                   gc.setTime(dt);         //this was missing
                   gc.add(Calendar.MONTH,+56);
                   System.out.println(date.format(gc.getTime()));

Maybe you are looking for

  • Files won't transfer from PC to Itunes

    All of a sudden, I can't add mp3 files which are on my PC to iTunes. They are able to be dragged from the folder on the PC but don't show up in iTunes. I've tried dragging them and also using the file/add file to library command but neither works. I'

  • Plot xy graph in specific zone

    Hi! I'm having a problem with my XY Graph. I collect data and show it on the graph where x-axis is between 0 and 100 for example. Then I have a button that will collect data again but just between 40 and 60 on the x-axis, so what I want to do is: - A

  • How to clean duplicate programs

    How do I check my MBP for duplicate programs and remove them?

  • MySQLNonTransientConnectionException

    Could someone read this and maybe suggest some different approaches to resolving this?? ERROR MSG: •Connection verification failed for data source: mysqldbv2 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create conne

  • How do i make my macbook never go into sleep?

    I want to have my macbook downloading something at night, but for some reason it keeps going into some sort of sleep and shows the annoying log in screen like when u close ur macbook and then opens it again after sleep. How can i remove this? Ive unc