European Style Date Converter - mm/dd/yyyy to dd.mm.yy

Hi, I am trying to write a program that reads a string for a date in the format mm/dd/yyyy and display it in the typical European format of dd.mm.yy
For example if the input is 03/13/2004 I'd like the output to appear as 13.03.04. Also I'd like it to use the JOptionPane for I/O.
Thanks very much!

alex_t88 wrote:
Hi, I am trying to write a program that reads a string for a date in the format mm/dd/yyyy and display it in the typical European format of dd.mm.yy SimpleDateFormat parse = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
I'll leave the rest for you. Check out parse and format methods, and read the javadocs.

Similar Messages

  • Converting a Java style date into useful format

    If I am calling a web service that returns a Java style date as a numeric value, such as 1177651563767 (milliseconds since 1 Jan 1970), how can I display this as a human readable date (hh:mm:ss dd-mm-yyyy? I have looked at the <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/40/a228173435437394f54c56de571ca4/frameset.htm">SAP help pages on date functions</a> and the
    <a href="https://wiki.sdn.sap.com/wiki/display/VC/DateandTime+Formats">wiki page on date and time formats</a>, but neither seems to help.
    My Java date is a numeric.
    Thanks

    Hi Michael,
    you can call the webservice with another webservice or an RFC and then use Java or ABAP to convert the value into the right format. My opinion is as you mentioned that there is no way with VC. Maybe you can use a time function (DADD as it is described <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/40/a228173435437394f54c56de571ca4/frameset.htm">here</a> and sum up to 01/01/1970 your [value in seconds]/60 this should work, but I never tested it.      
    Maybe this works, but this isn't a good solution anyway.
    Best Regards,
    Marcel

  • How to convert the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:M'

    How can i convert a the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:MI:SS AM' in Oracle
    I have a query
    select UPPER(t.val_10) "TYPE", count(val_3) "Number of Transfers"
    from table1 t
    where t.is_active = 1
    and t.val_4 = 'INBOUND'
    and to_date(to_date(val_5,'MM/DD/YYYY HH:MI:SS AM'), 'DD/MM/YY') between to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY') and add_months(to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY'),1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)
    I get the error [ORA-01861: literal does not match format string which i think is because
    val_5 has the values in the following format:
    8/29/2008 6:31:10 PM
    Does anyone have an answer?
    Thanks in advance
    Edited by: user2360027 on 26-Mar-2009 03:50                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    first off, you've got to_date(to_date(...)) - NEVER do this - you're forcing an implicit to_char which can cause all sorts of problems!
    What is the data type of your column val_5? If it's DATE then your query is simply:
    select UPPER(t.val_10) "TYPE",
           count(val_3) "Number of Transfers"
    from   table1 t
    where  t.is_active = 1
    and    t.val_4 = 'INBOUND'
    and    val_5 between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)If it's a varchar2 (why, oh why, oh why, ...?!), then your query should be:
    select UPPER(t.val_10) "TYPE",
           count(val_3) "Number of Transfers"
    from   table1 t
    where  t.is_active = 1
    and    t.val_4 = 'INBOUND'
    and    to_date(val_5, 'mm/dd/yyyy hh:mi:ss AM') between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)Remember that dates in DATE format are stored in an internal Oracle format - in order for you to tell Oracle that your string is a date, you need to use to_date. When you want to retrieve a date, you need to use to_char to put it into the format you want to see it in.
    Remember also that your nls_date_format defines the default format that you'll see a date, which is what is used in the implicit conversion that oracle does when you select a date:
    SQL> alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    26/03/2009 11:01:53
    1 row selected.
    SQL> alter session set nls_date_format='mm/dd/yy hh12:mi:ss AM';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    03/26/09 11:02:24 AM
    1 row selected.It doesn't make sense to convert something that's already in a DATE format into a DATE format - in order to do that, oracle has to first change the date into a string, and it does that by using the nls_date_format parameter setting - if you're working with dates-in-strings that are in a different format, then all sorts of problems arise, as you have found out!

  • How to convert a date from "yyMMddHHmmss" into "yyyy-MM-dd HH:mm:ss format

    hi
    please help i got the date "yyMMddHHmmss this format, how do i convert this into "yyyy-MM-dd HH:mm:ss" format using java code
    please help me anybody having idea

    YoungWinston wrote:
    jverd wrote:
    ...you don't need to know anything about dates or calendars to do that transformation, other than the rules for converting a 2-digit year to a 4-digit one.
    @OP: And for that, you have [SimpleDateFormat.set2DigitYearStart()|http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/text/SimpleDateFormat.html#set2DigitYearStart%28java.util.Date%29].
    WinstonRight. But I was talking about the case where we just use string manipulation directly, and skip DateFormat altogether. In this case we just need and if check against the int value of the first two digits.

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

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

  • 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

  • Converting date from DD.MM.YYYY  to  YYYY - MM - DD  format

    Hi All,
    Can you give me a way to convert date from DD.MM.YYYY  to  YYYY - MM - DD  format. Actually frm tables i am getting date in DD.MM.YYYY format.  And i want to print it in YYYY-MM-DD format.
    Please reply.
    Thanks And Regards,
    Mayank Verma
    Moderator message - Please search before asking. Date formatting is one of the most common questions asked - post locked
    Edited by: Rob Burbank on Jul 6, 2009 10:42 AM

    Hi,
    Hey you can make use of offset  and concatenate statement to convert the date.
    regards,
    Ankur Parab

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

  • Converting String foramt(yyyy-mm-dd) to java.sql.Date format(mm/dd/yyyy)

    Hi,
    I am new to this Technology.
    in my Project DataBase I have the date field as String in format yyyy-mm-dd. when I am trying to fetch this date through the front-end I need to see the date in dd/mm/yyyy format of type java.sql.Date Variable.
    if you know, Pl help me.
    Thanks in Advance,
    Kamala.

    Then use a SimpleDateFormat object to parse it into a Date object, and also to format the Date the way you want to see it, rather than simply relying on the toString() implementation.

  • How to convert dd.mm.yyyy into yyyymmdd??..

    I am reading input date as dd.mm.yyyy
    I want to convert it into yyyymmdd
    is there any function module???...
    Thanks
    Sri

    hi,
    Use convert_date_input or convert_date_internal.
    the previous is obsolete with respect to some of the systems and the later isn't obsolete.
    Use as per your requirement.,
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
        EXPORTING
          date_external              = input
    *     ACCEPT_INITIAL_DATE        =
        IMPORTING
          date_internal              = output
        EXCEPTIONS
          date_external_is_invalid   = 1
          OTHERS                     = 2
    Thanks
    Sharath

  • Date format mm/dd/yyyy to mmddyyyy

    Hi All,
    I would like to convert the date fromat from mm/dd/yyyy to mmddyyyy.
    Actually i'm taking into a variable n checking it & concatenating it.
    But I want to know any fm for this.
    I want to know in which format the date is entering my program, if the date is coming in mmddyyyy, then I have no issues, I want to go n display in the same format.
    but if it is coming in the different i want it to b converted. mm/dd/yyyy to mmddyyyy.
    Can any body let me if there is any FM , and also let me know how to check the Date Format.
    Regards
    Rohini devi

    hi,
       WRITE : sy-datum.
       DATA : dat TYPE d.
       dat = sy-datum.
       WRITE :/ dat.
    the above mentioned code will give u output
    o/p=> 22/05/2008 -
    this is the format which u have
             22052008   -
    this is wat u wanted
    so jst assgin the variable which has value in dd/mm/yyy to a variable of type d
    reward points if useful

  • Problem with  date format "dd-MM-yyyy"

    hi all,
    i am using jdev 10.1.3.2
    My application ADF Swing app.
    in my database i have a table employee which contains "birthday".
    my problem is that i must use date format"dd-MM-yyyy".
    i added this format into "formatinfo.xml" file.
    than i choose it in my EO.
    i create a form which contains employees.
    for example i have an employee with a birthday=25-10-1970
    in my text field if user puts "1970-10-25"'which is not the best format) he will have a correct result "25-10-1970"
    but if user puts "25-10-1970" he will have as result "21-02-0031" which is not the real value.
    please help me.
    thanks.
    PS: i did some research before posting but i didn't find yet

    Rouz,
    Did you try what i said before?
    * Open you EntityObject
    * Expand the attribute tree
    * Choose your DOB attribute
    * Choose the Control hints pane on the right
    * Choose Formater: Simple date format
    * Choose Format mask dd-MM-yyyy
    Run your application and try it.
    This is how i change the format and it works perfectly.
    I uses the correct format to show the date and it enables me to edit the date using the format mask dd-MM-yyyy
    Edit: I just tried it myself. I can only reproduce it by removing my mask. Ergo, the application expects the default american format yyyy-MM-dd. By entering a date in the format dd-MM-yyyy the framework will convert it to yyyy-MM-dd and you'll end up with 0031-02-21.
    CONCLUSION follow the steps i discribed above to set your mask and you'll be fine.
    Message was edited by:
    Smolders Johan

  • Problem in date converting into dbFormat()

    Respected Experts,
    I am get the current date into String vaiable and from this string variable i want to convert into dateformat.
    For converting to date format i write the .java file. It converts date correctly into format "dd/mm/yyyy" but i want date format into "dd/mm/yyyy HH:MM.pm/am", so what change should i do in my following progaram.
    import java.text.SimpleDateFormat;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class UtilityFunction
         public static String toUserFormatDate(Date dt)throws ParseException
         SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy");
         String str=sdf.format(dt);
         return str;
         public static java.sql.Date toDbFormatDate(String sdt)throws ParseException
         SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy");
         Date d=sdf.parse(sdt);
         SimpleDateFormat nsdf=new SimpleDateFormat("dd-MM-yyyy");
         String str=nsdf.format(d);
         Date nd=nsdf.parse(str);
         java.sql.Date rdate= new java.sql.Date(nd.getTime());
         return rdate;
         public static void main(String args[])throws ParseException
              SimpleDateFormat df=new SimpleDateFormat("dd-MM-yyyy");
              Date d2 =df.parse("08-09-1984");
              System.out.println("Date converted to User interface form");
              System.out.println("Database Date"+"08-09-1984");
              String p=toUserFormatDate(d2);
              System.out.println("Converted date"+p);
              java.sql.Date r=toDbFormatDate("12/12/2009");
              System.out.println("Date converted to database form");
              System.out.println("User Interface Date"+"12/12/2009");
              System.out.println("Converted date"+r);
    }

    After 22 posts on the forums, I'd have expected you to have learnt how to use the code tags by now (click on 'CODE' when posting)
    And while you get points for posting an SSCCE, you've left too much fluff in there. I don't know what method you want to discuss.
    And if you've reached this far with the SimpleDateFormat, what kept you from reading the rest of patterns available? It's all the same thing, you just needed to make it dd/MM/yyyy hh:mm a
    Do note that with your code, you're creating a date from a string that's missing the time, so you'll only get 12:00 AM all the time, for the above pattern. And also, you'd be using hh and not HH since putting AM/PM with 24 hour clock time is plain dumb.

  • Convert DD-MON-YYYY format to MM/DD/YYYY

    I have an input date variable L_DATE as 11-Aug-2013(DD-MON-YYYY).
    In my procedure, I am converting the input date to MM/DD/YYYY format .
    The logic I have used for the same in my Stored Proc- COMPARE2 is:
    R_DATE := to_char(to_date(L_DATE,'DD-MON-YYYY'),'MM/DD/YYYY');
    But this is the error that I get when the SP is run:
    ORA-01843: not a valid month
    ORA-06512: at "COMPARE2", line 51
    ORA-06512: at line 2
    Can anyone suggest how to resolve this??

    Input data doesnt match NLS_DATE_LANGUAGE setting
    Consider
    select * from v$nls_parameters
    where
    parameter ='NLS_DATE_LANGUAGE'
    PARAMETER VALUE
    NLS_DATE_LANGUAGE AMERICAN
    select
    to_char(to_date('11-MAY-2013','DD-MON-YYYY'),'MM/DD/YYYY') d
    from dual
    D
    05/11/2013
    select
    to_char(to_date('11-MAY-2013','DD-MON-YYYY','NLS_DATE_LANGUAGE=GERMAN'),'MM/DD/YYYY') d
    from dual
    ORA-01843: not a valid month
    or
    The month is not given literally
    select
    to_char(to_date('11-05-2013','DD-MON-YYYY'),'MM/DD/YYYY') d
    from dual
    ORA-01843: not a valid month

Maybe you are looking for

  • Error when connecting more than 50 users ??

    I use database 8iEE & form server (9ias rel1) on different box to deploy form on the web the error occur when user connect more than 50, but it's ok when connect to database using sqlplus Is there someone has the same experience ?

  • SOA Enterprise Manager Page not coming up

    Hi, I have installed a mid-tier version of SOA Suite. I am not able to get the App. Server Enterprise Manager. Here is the link that I am trying but it always comes back with Page cannot be found: http://localhost:7779/em Other controls works i.e. BP

  • FMCG in SAP B1

    Hi All, Is it possible to use SAP B1 in the fast moving consumer good industry ? what is its limitation and what is its benefit ? I mean what modules are usually able to be applied in such industry ? Pls give advice. Thanks Rgd Rajh

  • To change the status of Audit ?

    Hi, If any knows the Function Module to change the status of Audit please let me know. I want to change the status of Audit(PLMD_AUDIT) through program. So please provide me the FM. Thanks

  • Can't open Premiere Pro after set-up

    After a successful download of Premiere Pro CS5.5, I clicked on the Set-up app under the Adobe Premiere Pro CS5.5 Functional Content folder, followed the instructions, finished the set-up with no problems. Now I can't figure out how to run the progra