How to parse date in yyyyMMddHH'.'mmss'00' format

Hi all,
In an applet I am creating, I receive a timestamp in the following format:
yyyyMMddHH'.'mmss'00'
As an example, the date string I receive is "2003011419.304600" which, when decoded, gives, Jan 14 19:30:46 2003.
I need to convert this to the MM/dd/yyyy format for date and HH:mm:ss:SS for time, in order to display it in my applet.
Here is the scheme I am using:
String inputDateFormat = "yyyyMMddHH'.'mmss'00'";
SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat timeFormatter = new SimpleDateFormat ( "HH:mm:ss:SS");
SimpleDateFormat formatter = new SimpleDateFormat ( inputDateFormat );
// Assume the tokens vector contains the correct string
Date dateTime = formatter.parse ( ( String ) tokens.elementAt ( 0 ) );
String date = dateFormatter.format ( dateTime );
String time = timeFormatter.format ( dateTime );
However, I am getting parse exception, Unparseable date error at the following line:
Date dateTime = formatter.parse ( ( String ) tokens.elementAt ( 0 ) );
Is this because the date format does not contain any delimiters (like space or period or slash)? I am kinda confused.
Thanks,
Alan

What I am wondering is
whether the date can be successfully parsed even if it
is in the strange format as above.My guess at this point in time is that this is a bug. I did not find anything in the bug database that suggested that it is known.
The following code demonstrates it.
Please post it (or let me know so I can post it.)
I am using build 1.4.0-b92, so if someone could try it on 1.4.1 it would be nice.
     String s;
     SimpleDateFormat f;
     java.util.Date d;
     // Works
     s = "2003011419.3046";
     f = new SimpleDateFormat("yyyyMMddHH.mmss");
     d = f.parse(s);
     System.out.println("date with no specials=" + d);
     // Works with 'a' at end
     s = "2003011419.3046a";
     f = new SimpleDateFormat("yyyyMMddHH.mmss'a'");
     d = f.parse(s);
     System.out.println("date with a at the end=" + d);
     // Works with '>' at end
     s = "2003011419.3046>";
     f = new SimpleDateFormat("yyyyMMddHH.mmss'>'");
     d = f.parse(s);
     System.out.println("date with > at the end=" + d);
     // Doesn't work with '0'(zero) at end
     s = "2003011419.30460";
     f = new SimpleDateFormat("yyyyMMddHH.mmss'0'");
     d = f.parse(s);
     System.out.println("date with digit at end at the end=" + d);

Similar Messages

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

  • I need how to load data from MS Excel(csv format) to NW Excel

    Hi,
    I am doing Migration project from SAP MS to NW Manually.
    I need how to load data from MS excel (csv format) to NW excel .
    For example 2008 budget data.
    Could you please help me in this.
    Thanks and Regards
    Krishna

    Hi,
    You need to create a transformation file and a conversion file if required. First upload the excel (csv) file into BPC using Manage Data and Upload File option.
    Create the transformation file (refer to the sap help  on how to define a transformation file). You need to specify the mapping correctly and include all your application dimensions and map them to appropriate columns of the flat file.
    Before running the import package, do validate the data in the flat file you uploaded into BPC with the transformation file you created.
    Thanks,
    Sreeni

  • How to add date in MM/DD/YYY  format at the end of a string

    Hi
    I want Description to look like
    ' PARTICIPATION ON TEMPORARY TV SHOW EXPIRING ' and include the "latest show expiration date" as "MM/DD/YYYY"
    Pls help ......
    try {
                            Date date= new Date();
                             System.out.println("THE TODAYS DATE is :"+date);
                               DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    //                         DateFormat df = new SimpleDateFormat("MM/DD/YYYY");   -----> Its not allowing this format ????????
                             begin_Date = hashDateE.get(id);
                             System.out.println("THE LATEST TV SHOW DATE is :"+begin_Date);
                             Date d1 = df.parse(begin_Date);
                             String relation;
                             if(d1.equals(date))
                                  relation = "both the dates are same";
                             else if(d1.before(date))
                                  relation = "BEFORE";
                             else
                                  relation = "AFTER";
                             //System.out.println(d1 + "is" + relation + ' ' + date);
                             if("10".equals(latestShow)){
                              if("BEFORE".equals(relation)){
                                   System.out.println("The latest show date is expired");
                              Code =3;
                              Description = "PARTICIPATION ON TEMPORARY TV SHOW EXPIRED ";
                              else if("AFTER".equals(relation)) {
                                   System.out.println("The latest show date is non expired");
                                  Code = 2;
                                   Description = "PARTICIPATION ON TEMPORARY TV SHOW EXPIRING" + d1; -------------> I TRIED THIS WAY ( d1 should be in this format MM/DD/YYY
                              }else {
                                   System.out.println("The latest show date is non expired");
                                 Code = 20;
                                  Description = "PARTICIPATION ON TEMPORARY TV SHOW EXPIRING" + d1;
                        

    If you have a string like 2008-12-15 and you want to interpret it as a date and format it as 12/15/2008, then you need two DateFormat objects.
    One to parse the String in the first format into a Date, -------> i could do this
    try {
              String begin_date = "2008-12-15";
              System.out.println("The begin date is :"+begin_date);
              DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
              Date d1 =  df.parse(begin_date);
              System.out.println("the Date value is d1 :"+d1);
    catch() {
    }Output is :The begin date is :2008-12-15
    the Date value is d1 :Mon Dec 15 00:00:00 EST 2008
    Pls help me with the second part :- ?????/
    and one to format that Date into a String in the second format. MM/dd/yyyy --- how to do this ..after i tried several times with different statements , i am asking this piece of code to achieve this

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

  • How to get date in dd/mm/yyyy format ?

    Hello,
    for this query :
    >select to_date(to_char(sysdate),'dd/mm/yyyy') from dual;
    i wanted to get date in dd/mm/yyyy format , but this query is not returning in correct date format .
    How to get that ?

    select id,
    to_date(to_char(dt1,'mm/dd/yyyy'),'dd/mm/yyyy') dt1,
    to_date(to_char(dt2,'mm/dd/yyyy'),'dd/mm/yyyy') dt2
    from t_table1 where no=23;This is my actual query.
    But this query is giving error.
    ORA-01843: not a valid monthWhen i issued this query :
    select id,dt1,dt2 from t_table1 where no=23 ;
    this is the output :
    ID DT1 DT2
    001 10/7/2011 10/19/2011Edited by: bootstrap on Oct 8, 2011 2:13 PM
    Edited by: bootstrap on Oct 8, 2011 2:13 PM

  • How to parse data from a text file with no convenient delimiters?

    I need to read data from a text file.  This file contains one line of data with the repeating pattern "time 00 ADVar2: ___ Height: ____ time 01 ADVar2: ___ Height: ___ ..."  I need LabView to parse out the "time" and "height" values, build an array with the values, and graph the correlation on an X&Y plot.  Does Labview have an automated way to read to the input data file and parse out the correct values, even without convenient delimiters?  Thank you.

    You actually do have a convenient delimiter: "time". Thus, you can make an array using that as the delimiter. Only caveat is that the first array element will be empty. Then you can conveniently use the Scan From String function in a for-loop. Something like this:
    Message Edited by smercurio_fc on 11-21-2008 03:13 PM
    Attachments:
    Example_VI.png ‏9 KB

  • How to parse data from XML with prefix?

    Hi folks,
    I have an XML which tags include prefixes. I would like to parse it using a select. Any ideas?
    [Sample XML|http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501]
    I tried this:
    select xml
    from
       (  select
                httpuritype('wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501').getXML() xml
          from dual
        );This just returns XML.
    select  x.ico,
            x.org_name
        from dual d
             ,XMLTABLE('/are:Ares_odpovedi/are:Odpoved/D:Vypis_OR'
                        PASSING httpuritype('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501').getXML()
                        COLUMNS
                           ico varchar2(50) PATH 'D:ZAU/D:ICO'
                          ,org_name varchar2(200) PATH 'D:ZAU/D:OF'
                        )  x
       where rownum = 1
    ORA-19228: XPST0008 - undeclared identifier: prefix 'are' local-name 'are:Ares_odpovedi'Any idea how to simply get all details into columns?
    Thanks,
    Tomas

    add xmlnamespaces to xmltable
    select  x.ico,
            x.org_name
        from XMLTABLE(
             xmlnamespaces('http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer_or/v_1.0.3' as "are"
             , 'http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_datatypes/v_1.0.3' as "D"),
             '/are:Ares_odpovedi/are:Odpoved/D:Vypis_OR'
                        PASSING httpuritype('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_or.cgi?ico=46972501').getXML()
                        COLUMNS
                           ico varchar2(50) PATH 'D:ZAU/D:ICO'
                          ,org_name varchar2(200) PATH 'D:Vypis_OR/D:ZAU/D:OF'
                        )  x
       where rownum = 1not tested

  • How to parse ".dat" file using java?

    Hi experts/friends,
    I need to parse the ".dat" files such as "history.dat" of Firefox history and "index.dat" of IE history...
    I cannot able to parse those files.
    Can anyone suggest me or help me....

    Google ( [url http://www.google.com/search?q=firefox+history+file+format]firefox history file format )
    Google ( [url http://www.google.com/search?q=internet+explorer+history+file+format]internet explorer history file format )

  • How to download data into a text file format ?

    Hi, all.
    My situation now is: I have a report pogram which can retrieve data from database, and I would like to export or download those data to outside as a text file (.txt) in my local computer.
    So, does anyone know how to do it? i mean my report coding should add on or enhance with what coding in order to do like that.
    Thanks in advance.

    Hi,
    Use GUI_DOWNLOAD Function module.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                  =
        filename                      = 'FILEPATH'* 
    FILETYPE                      = 'ASC'
      APPEND                        = ' '
       WRITE_FIELD_SEPARATOR         = 'X'  (Field separator )
      HEADER                        = '00'
      TRUNC_TRAILING_BLANKS         = ' '
      WRITE_LF                      = 'X'
      COL_SELECT                    = ' '
      COL_SELECT_MASK               = ' '
      DAT_MODE                      = ' '
      CONFIRM_OVERWRITE             = ' '
      NO_AUTH_CHECK                 = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      WRITE_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      tables
        data_tab                      = t_customer ( give internal tablename )
    EXCEPTIONS
       FILE_WRITE_ERROR              = 1
       NO_BATCH                      = 2
       GUI_REFUSE_FILETRANSFER       = 3
       INVALID_TYPE                  = 4
       NO_AUTHORITY                  = 5
       UNKNOWN_ERROR                 = 6
       HEADER_NOT_ALLOWED            = 7
       SEPARATOR_NOT_ALLOWED         = 8
       FILESIZE_NOT_ALLOWED          = 9
       HEADER_TOO_LONG               = 10
       DP_ERROR_CREATE               = 11
       DP_ERROR_SEND                 = 12
       DP_ERROR_WRITE                = 13
       UNKNOWN_DP_ERROR              = 14
       ACCESS_DENIED                 = 15
       DP_OUT_OF_MEMORY              = 16
       DISK_FULL                     = 17
       DP_TIMEOUT                    = 18
       FILE_NOT_FOUND                = 19
       DATAPROVIDER_EXCEPTION        = 20
       CONTROL_FLUSH_ERROR           = 21
       OTHERS                        = 22 .
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.                                 " IF SY-SUBRC

  • How to display data in table with specified format?

    Hi,
    Jdev 11.1.1.4, ADF BC and ADF Faces
    In my application I have created a EO based view object which will return data as below.
    Deptid       Loc          seq
       1            Loc1         1
       1            Loc2         2
       2            Loc1         3
       2            Loc2         4
       3            Loc1         5
       3            Loc2         6Now I have to display the data in table like below
                     Loc1
       1                              1st row
                     Loc2                  Loc1
       2                              2nd row
                     Loc2                  Loc1
       3                             3rdrow
                     Loc2 How can I do that? Any help will be appreciated.
    ~Abhijit
    Edited by: Abhijit Dutta on Nov 5, 2011 6:18 PM

    check this thread...
    display the data in chart format

  • How to insert date in mmm/dd/yyyy format

    hi all,
    im getting date from user-interface in the format of mmm/dd/yyy.
    when i tried to insert data in this format,
    insert into temp values('10-july-2000);
    insert into temp values('july-10-2000');
    the first statement is working fine. and the second statement is givine msg,
    SQL> insert into temp values('10-july-1999');
    1 row created.
    SQL> insert into temp values('july-10-1999');
    insert into temp values('july-10-1999')
    ERROR at line 1:
    ORA-01858: a non-numeric character was found where a numeric was expected
    how to get this.
    regards
    pavan

    I have read that ALTER SYSTEM changes will be effective immediately and there is no need to bounce the database.
    right but if parameter is "modifiable" if not then we need to "restart database"
    there three parameter with "alter system .... cmd"
    1. Memory
    2. Spfile ------------effect in next startup
    3. Both ( Memory + spfile) Default
    hope this helps
    Let take example : PROCESSES is not modifiable parameter.
    SQL> show parameter process
    NAME                                 TYPE        VALUE
    processes                            integer     150
    SQL> alter system set processes = 152 scope=both
      2  /
    alter system set processes = 152 scope=both
    ERROR at line 1:
    ORA-02095: specified initialization parameter cannot be modified
    SQL> alter system set processes = 152 scope=memory
      2  /
    alter system set processes = 152 scope=memory
    ERROR at line 1:
    ORA-02095: specified initialization parameter cannot be modified
    SQL> alter system set processes = 152 scope=spfile;
    System altered.
    SQL> show parameter processes
    NAME                                 TYPE        VALUE
    processes                            integer     150
    SQL> startup force
    ORA-01031: insufficient privileges
    SQL> conn sys as sysdba
    Enter password:
    Connected.
    SQL> startup force
    ORACLE instance started.
    Total System Global Area  171966464 bytes
    Fixed Size                   787988 bytes
    Variable Size             145488364 bytes
    Database Buffers           25165824 bytes
    Redo Buffers                 524288 bytes
    Database mounted.
    Database opened.
    SQL>
    SQL> show parameter processes
    NAME                                 TYPE        VALUE
    processes                            integer     152
    SQL>Message was edited by:
    user52

  • How to print date in dd/MM/yyyy format??

    Hi All,
    I want to print a date in a dd/MM/yyyy format. I am doing like this
    Date d = new Date(23-11-2006); but it is printing
    like Wed Dec 31 18:59:58 EST 1969 .
    Please help me .

    I am doing like this
    Date d = new Date(23-11-2006); but it is
    printing No you're not, because that won't compile. Show us exactly what you're doing and we might be able to help.
    You seem to suggest you want to print a date in a certain format, but then the (pseudo-) code you present seems to suggest you want to be able to parse a date from a given format into a Date object.
    Be clear and specific about exactly what you want, what you have tried, and why it didn't work and then people will be better placed to help! :-)

  • How to display date field in ALV in format 'YYYY-MM-DD'?

    Hi experts,
    I am not getting displayed the date field in ALV in the format 'YYYY-MM-DD' if it is different than my user setting's format (DD.MM.YYYY).
    Tried with the edit mask
    LVC_S_FCAT-EDIT_MASK = '____-__-__'  but it does not work.
    I could not find the conversion routine for this. Is it possible to write customer conversion routine?
    I have to use DATE field, otherwise if I display this format in CHAR10 field , sorting in ALV does not work for this field.
    PLEASE ANY HELP!
    Kind regards,
    Danijela

    Hi,
    Use FM FORMAT_DATE_4_OUTPUT.
    TYPE-POOLS : slis, KKBLO.
    TYPES: BEGIN OF t_data,
           sel     TYPE char1,
           matnr   TYPE matnr,
           bldat   type char10,
           END OF t_data.
    DATA: it_tab TYPE STANDARD TABLE OF t_data,
          it_fcat TYPE slis_t_fieldcat_alv.
    DATA: wa_tab TYPE t_data,
          wa_fcat TYPE slis_fieldcat_alv,
          wa_layout type SLIS_LAYOUT_ALV.
    data: lv_repid    TYPE syrepid.
    data : lv_date    type NLEI-IBGDT,
           lv_outdate type RN1DATUM-DATEX,
           lv_format  type RN1DATUM-FORMAT value 'YYYY-MM-DD'.
    lv_repid = sy-repid.
    lv_date = sy-datum.
    CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
      EXPORTING
        datin         = lv_date
        format        =  lv_format
    IMPORTING
       DATEX         = lv_outdate.
       move lv_outdate to wa_tab-bldat.
    wa_tab-matnr = '0000001'.
    APPEND wa_tab TO it_tab.
    lv_date = sy-datum + 1.
    CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
      EXPORTING
        datin         = lv_date
        format        =  lv_format
    IMPORTING
       DATEX         = lv_outdate.
       move lv_outdate to wa_tab-bldat.
    wa_tab-matnr = '0000002'.
    APPEND wa_tab TO it_tab.
    lv_date = sy-datum + 2.
    CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
      EXPORTING
        datin         = lv_date
        format        =  lv_format
    IMPORTING
       DATEX         = lv_outdate.
       move lv_outdate to wa_tab-bldat.
    wa_tab-matnr = '0000003'.
    APPEND wa_tab TO it_tab.
    wa_fcat-fieldname = 'SEL'.
    wa_fcat-ref_fieldname = 'XCHPF'.
    wa_fcat-ref_tabname = 'MARA'.
    wa_fcat-edit = 'X'.
    wa_fcat-checkbox = 'X'.
    APPEND  wa_fcat TO  it_fcat.
    CLEAR :  wa_fcat.
    wa_fcat-fieldname = 'MATNR'.
    wa_fcat-ref_fieldname = 'MATNR'.
    wa_fcat-ref_tabname = 'MARA'.
    APPEND  wa_fcat TO  it_fcat.
    CLEAR :  wa_fcat.
    wa_fcat-fieldname = 'BLDAT'.
    wa_fcat-ref_fieldname = 'BLDAT'.
    wa_fcat-ref_tabname = 'BKPF'.
    APPEND  wa_fcat TO  it_fcat.
    call 'REUSE_ALV_GRID_DISPLAY'' after this
    Edited by: Ankur Parab on Oct 1, 2009 2:50 PM
    Edited by: Ankur Parab on Oct 1, 2009 2:51 PM

  • How to Extract data from HFM in ANSI format?

    We want the .dat file from Extract data in ANSI format. Currently this file is created by default in Unicode format. I tried unchecking the 'Save all files in Unicode format' option in Consolidation tab under Preferences, but for some reason the change is not getting saved.
    Does unchecking of this option change the file format?
    Is there any other option to change the file format ?
    What is required to be done to save the changes made in Preferences?
    I am using HFM 9.3.1
    Edited by: Amit Kumar on May 20, 2009 7:52 PM

    Any info on this issue?
    The changes made in preferences are not getting saved for some users. Is this related to role assigned?

Maybe you are looking for