Date display in dd-mmm-yyyy format on opening a .jsp file as .xls

Hi,
I am pretty new to Java and JSP, I have a problem,
There's an application in which the contents of a .jsp are to be displayed in excel format.
All the data are displayed in correct format except the dates.
The dates that are in the dd-MMM-yyyy format in the .jsp's are displayed as dd-mmm-yy in the .xls file.
How to solve this?
Thanks in Advance!

Maybe you need to configure that "application"? Or if you actually have access to the source code, then just take a look in it.
Without any more details about the "application" we can't help you any much further.
Generally, when you want to convert a Date or Calendar object to a human readable String, the SimpleDateFormat [1] is been used.
[1] http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html

Similar Messages

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

  • SSRS Datetime Parameter value should display in DD/MM/YYYY format

    Hi All
    we have 2 Datetime parameters in my report , where the value is shouwing in MM/DD/YYYY format . i have modified the language type of report to Fr-BE but there is not change . Users want to see the date value in DD/MM/YYYY format . how can we achieve this
    Surendra Thota

    I have this same issue on my new laptop (suffering with it for about 9 months actually).  I used to work around it by launching Visual Studio as a different user.  That doesn't work anymore as I can't get the report preview to display when run
    as another user (apparently that's an issue reported in other forum threads).
    I lodged something on Connect about this quite a while ago and the op there was also quite unhelpful.  Using expressions and so on is NOT an option.  It's impossible to preview a report using date pickers now as it seems the control validates using
    one format and then the engine seems to immediately validate using the other.  I suppose an ambiguous date like 3/2/2013 (Feb or March?) would "work" but is hardly nice.  There's a lot more detail in this thread
    http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/a5e40392-2bf8-432e-89f5-3a948fc3ea7a and the subsequent Connect issue I filed
    https://connect.microsoft.com/SQLServer/feedback/details/750202/date-picker-in-reporting-services-2008-r2-visual-studio-designer-wrong-formatting#tabs .
    The new SQL 2012 tools that were released a couple of months ago that us VS2012 as the designer still have the same flaw.  I've just tried opening a Microsoft support incident but the issue opening tool seems broken as any selection of a SQL Server
    product results in 404s :(
    Anyway, the other forum thread may be able to help others or at least help clarify the problem we're experiencing.  I'm apply CU4 for SQL 2012 at the moment plus I saw there's a release of the VS2012 "BIDS" tools to get on the CU4 page - maybe it's
    a new version?  I'm hoping so :)
    Ian Yates Technical Manager Medical IT Pty Ltd PO Box 501, Carina QLD 4152 Australia Web: www.medicalit.com.au

  • Convert yyyy-MM-dd format to dd-MMM-yyyy format

    Hi,
    I want to Convert a string which is in yyyy-MM-dd format to a dd-MMM-yyyy date object.
    Note: want to convert it as a date object not as a String.

    You don't need to change the format to create a Date object! Like delta said above, Date objects do not have formats! Date objects have their own, unchangeable internal representation. The only time you need to worry about the format of a Date is when you display it to a user...in which case you use a DateFormat object, like SimpleDateFormat, which can create a Date from a String, or a String from a Date, in whatever format you choose.

  • Problems converting FILETIME date/time into MM/DD/YYYY format...

    Has anyone successfully converted a FILETIME date/time value into a MM/DD/YYYY format using ColdFusion? I am failing drastically, and it seems like an easy conversion.
    FILETIME format (details: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284(v=vs.85).aspx) is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
    A database I'm working with has such values, and I want to display them in a user-friendly date format within my application.
    For example, one record is:
    13003368600
    The above number represents the following date and time:
    1/22/2013 @ 2:50 PM
    Sadly I know this only because the FILETIME value gets written to the database by a third-party application, and within that application I specify it in the MM/DD/YYYY format.
    Can anyone offer me some guidance, or better yet has anyone accomplished this already and want to share code?

    I did this, on cf9/linux, and it seemed to do the trick:
    <cfscript>
    Long = createObject("java","java.lang.Long");
    Date = createObject("java","java.util.Date");
    fileTimeToEpoch =
    // take pwdLastSet From Active Directory, it's in filetime
    pwdLastSet = JavaCast("long", Long.parseLong("130292682204519505"));
    // take filetime and turn it into epoch/java - 1970/1/1
    // http://www.silisoftware.com/tools/date.php - converted: jan 1, 1970 00:00 -00
    javaTime = JavaCast("long", pwdLastSet - 116444736000000000);
    // convert to milliseconds
    javaTime = JavaCast("long", javaTime / 10000);
    today = JavaCast("string", Date.init(javaTime));
    </cfscript>
    <cfdump var="#pwdLastSet#">
    <cfdump var="#javatime#">
    <cfdump var="#today#">

  • Date validation in "DD-MON-YYYY" Format,

    Hi ,
    I have created a textbox with date picker as (dd-mon-yyyy) .
    Now i want to create a validation on it for the format (dd-mon-yyyy) .
    I have created a pl/sql code with type "function returning error text".
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    if :P4_END_DATE != to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    end if;
    END IF;
    End;
    When i type in like 20-NOV-08 it gives error as 'START DATE should be in "DD-MON-YYYY" Format',
    but when i change month like 20-11-2008 , it actually gives error
    ORA-01843: not a valid month
    Error ERR-1024 Unable to run "function body returning text" validation.

    Vaibss wrote:
    Hi ,
    I have created a textbox with date picker as (dd-mon-yyyy) .
    Now i want to create a validation on it for the format (dd-mon-yyyy) .
    I have created a pl/sql code with type "function returning error text".
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    if :P4_END_DATE != to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    end if;
    END IF;
    End;
    When i type in like 20-NOV-08 it gives error as 'START DATE should be in "DD-MON-YYYY" Format',
    but when i change month like 20-11-2008 , it actually gives error
    ORA-01843: not a valid month
    Error ERR-1024 Unable to run "function body returning text" validation.The call to 'to_date' is raising an exception when it tries to convert your date, standard PL/SQL exception handling takes over and the rest of your code is ignored.
    You could try:
    declare
    pragma exception_init(invalid_date,-01830);
    l_dummy date;
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    l_dummy := to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    END IF;
    exception
    when invalid_date then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    End;
    but even that will not check that the user actually used your desired format - the to_date can be quite flexible e.g. accepting separators other than the '-' that you have declared. In fact, the above would only catch the user entering a 'date' that is shorter than the format string - changing the 'invalid_date' for 'others' would capture more (all!) exceptions.
    You probably want to look at using regular expressions to perform the format validation.
    Edited by: Andy Hardy on Nov 25, 2008 12:29 PM

  • Date field in DD.MM.YYYY format printing as MM.DD.YYYY

    HI all,
    There is a DATE field FKDAT in an invoice whose value is in DD.MM.YYYY format (01.07.2010).
    In the print program, this value is being passed into a CHAR field. However, when it gets printed it prints in MM.DD.YYYY format (07.01.2010).
    I have already checked the user settings under Own Data and it is in the DD.MM.YYYY format.
    Please advise.
    Thanks and regards,
    Anishur
    Moderator message: date formatting questions = FAQ, please search before posting.
    locked by: Thomas Zloch on Aug 12, 2010 4:08 PM

    Hi ,
    In the invoice printing program you should use 'WRITE'  syntax  which will write the date as per user's date format.
    e.g  write it_tab-fkdat to gv_date.
    Declare gv_date as character 10.
    Narayan

  • Display BEGDA data element with dd/mm/YYYY format

    Hi,
    in my programm i use table HRP1002 in which there is a field BEGDA (NUM8) and i want to display it with dd/mm/YYYY, so i must obligatorily convert this field or there is a another technics ?
    Regards.

    You can also do something like
    WRITE DATE  USING EDIT MASK '__.__.____'.
    Hope this’ll give you idea!!
    <b>P.S award the points.!!! !!!</b>
    Good luck
    Thanks
    Saquib Khan
    "Some are wise and some are otherwise"

  • Date show in dd/mm/yyyy format

    hey.....my database generates date in xml in following format
    <date>1993-02-27T00:00:00+05:30</date>
    i wish to show and sort this date in the form 27-02-93
    how can i do it?

    You can ask your database to return it in the format you
    want, assuming SQL is used for the query there are date format
    functions that can be used, or you can use javascript to parse and
    format the date after you receive it. Of course this means you have
    to have some skills in SQL or javascript.
    Nathan

  • Date validation in dd/mm/yyyy format

    hi,
    I am using SimpleDateFormat to validate date but it not working properly It is not validating against date range and leap year.
    String stringDate = "40/02/1999";
    try
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    ParsePosition pos = new ParsePosition(0);
    Date date = formatter.parse(stringDate, pos);
    System.out.println("correct");
    catch (Exception e)
    e.printStackTrace();
    }

    Have a look at the calendar class, in particular :
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Cale
    ndar.html#setLenient(boolean)Calendar isn't needed here. He sould stick with SDF.Infernal jverd !! ;-P
    For some reason i skipped over your reply completely, and I knew there was a setLenient in Calendar, so I was going to point him there. OP listen to jverd.

  • Update Date field with mm/dd/yyyy format

    I have a Field with Date Type then I have to update it with sysdate but only with the mm/dd/yyyy (not TIME)
    I make:
    UPDATE TABLE
    SET DATE_FIELD = to_date(to_char(sysdate, 'mm/dd/yyyy'),'mm/dd/yyyy')
    Is There a better way to do it?????
    Thanks!

    You can use
    trunc(sysdate)
    for the insert.
    Regards,
    Gerd

  • Date format throughout the site should be dd-MMM-yyyy

    I want all dates in the site to be displayed in "dd-MMM-yyyy" format.
    I want to achieve this using regional settings and don't want to use ddwrt:FormatDate function at each page where date is displayed. What settings I need to do.
    Please help me to resolve this.
    Vaibhav Chitode

    it should be done using regional settings, if still you are not getting same format then apply below code. you can execute following code can using a console app/windows forms app.
    using Microsoft.SharePoint;
    using System.Globalization;
    try
    CultureAndRegionInfoBuilder.Unregister("en-US");
    catch { }
    CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder("en-US", CultureAndRegionModifiers.Replacement);
    carib.LoadDataFromCultureInfo(new CultureInfo("en-US"));
    carib.LoadDataFromRegionInfo(new RegionInfo("en-US"));
    carib.GregorianDateTimeFormat.ShortDatePattern = "dd-MMM-yyyy";
    carib.Register();
    CultureInfo ci = new CultureInfo("en-US");
    string siteUrl = string.Empty;
    Console.WriteLine("Enter site url:");
    siteUrl = Console.ReadLine();
    using(SPSite site = new SPSite(siteUrl))
    using(SPWeb web = site.RootWeb)
    web.Locale = ci;
    web.Update();
    Console.WriteLine("Done");
    Console.ReadLine();
    After running this code, your site will remain as en-US in this case and will display the date in the format defined.
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer :)

  • How to change the date format in Sharepoint 2010 to dd MMM yyyy

    Hi,
    I am looking to change the datetime format with in the modified column from mm/dd/yy to dd MMM yyyy. I dont want to create calculated field with dd MMM yyyy format. I want the actual modified column value to be represented as dd MMM yyyy format.
    Thanks for your help in advance.
    regards
    Kalyan

    I'm not really sure what context you asking to change this for but to change your date time settings -
    Go into Site Settings and under 'Central Administration' there is a link to 'Regional Settings'. Click this and you specify the way dates and times are displayed.
    I have done this and mine displays as DD/MM/YYYY like you are asking.
    My locale is current set to English (United Kingdom) and sort order is general. Even if you're not in the United Kingdom, I can only see this way being your solution as US dates are always set as MM/DD/YYYY.
    http://sharepointythings.blogspot.co.uk

Maybe you are looking for