Urgent !!! Date Format Validation Problem

hi,
I'm using the following code to validate a date,
     SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
     String dateStr = "03/30/20xx";
     try{
          sdf.setLenient(false); // For Strict Validation.
          System.out.println(sdf.parse(dateStr));     
          System.out.println("Valid Date " + dateStr);
     }catch(Exception ex){
          System.out.println("Invalid Date " + dateStr);
It works fine for input values like 03/30/2005, 03/30/xxxx, 03/3x/2005
but fails for 03/30/20xx.
where c is any non-numeric character.
Please tell me a solution for this. Is there any other way to do this.

Oh! Now I understand!
try this:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
String dateStr = "03/30/20xx";
try {
     sdf.setLenient(false); // For Strict Validation.
     ParsePosition pos = new ParsePosition(0);
     System.out.println(sdf.parse(dateStr, pos));
     System.out.println("Valid Date " + dateStr + " up to position " + pos.getIndex());
} catch (Exception ex) {
     System.out.println("Invalid Date " + dateStr);
}

Similar Messages

  • How to remove the date format validation done by the UI

    Hi All,
    I am having a date field which is an input field for Dateof Birth. User can either select from the calendar or enter his own date. If the user enters invalid date format'(032342525') something like this, when we move to the next tab the column turns to Red and it displays a message saying that date is not a valid date. I wanted to validate that on Save instead of tab click.
    Can anyone of you tell me how can we remove this date format validation in Java Webdynpro.
    Thankyou for your time and consideration!
    Madhavi

    Thankyou for your reply. I cannot the change the date type to string bcas the users need date picker to select the date. The problem I am having is once the format is wrong and the UI validates, though the other fields are entered by the user the application returns error saying that the required field are not entered.
    And also I am having multiple containers in my view set and for all other error messages I am using a popup to display the messages and this only error is shown at the bottom of the page which the users does'nt like.
    Is there any way I can identify that format error occured before it throws on the UI screen??
    Regards,
    Madhavi

  • Data format inconsistency problem on Discoverer 4i plus and Desktop 4.1

    I encountered 'data format inconsistency' problem when using
    Discoverer 4i plus web version vs Desktop version 4.1 to run the
    same report :-
    The result returned by Desktop version is as following:-
    Employee Count Percent Employee Count
    Mgt 202 18%
    Occ 891 81%
    Other 1 0%
    Percent 1094 100%
    The result returned by 4i web version is like the following:-
    Employee Count Percent Employee Count
    Mgt 202 18%
    Occ 891 81%
    Other 1 0%
    Percent 109400% 100%
    Pls note that the Employee count column is 1094 in Desktop
    version whereas in web version it's 109400%
    After I export the data to Ms Excel, I obtained below result :-
    Employee Count Percent Employee Count
    Mgt 202 0.184644
    Occ 891 0.814442
    Other 1 0.000914
    Percent 1094 1
    I would like to know if this is Oracle Discoverer bug or it's a
    known issues ?
    Pls advise.
    Thanks in advance.

    Hi Discoverer Technical Team,
    Could u pls response to that issue ?
    Thanks and regards.

  • Urgent date format problem

    Hi every one
    I have a problem with date format in my database.
    I am using Oracle8 Release 8.0.4.0.0 - Production server.
    Generally all procedures in my application runs with the date format DD-MON-YY
    I dont know suddenly what happens to this format and it changes to YYYY/DD/MM
    and all my procedures will run with the format YYYY/DD/MM then nothing happens in the database.
    Please tell me why this date change happening
    Thanks
    ...

    One possible reason :
    TEST@db102 SQL> select sysdate from dual;
    SYSDATE
    13-AUG-06
    TEST@db102 SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [ora102 ~ db102]$ export NLS_DATE_FORMAT=YYYY/MM/DD
    [ora102 ~ db102]$ sqlplus test/test
    SQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 13 12:03:19 2006
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    TEST@db102 SQL> select sysdate from dual;
    SYSDATE
    2006/08/13
    TEST@db102 SQL>                                                                                    

  • Date Format Conversion Problem

    Hi I am having trouble converting excel files to PDF.
    I am in Australia and so we use the date format dd/mm/yyyy.
    However when I convert to PDF it changes the date to the American format mm/dd/yyy.
    For example if the date in Excel is 07/08/2013 (7th of August 2013) after conversion to PDF it displays as the 08/07/2013 (8th of July 2013).
    Can someone please tell me how to get Adobe CreatePDF to convert to the correct date format?

    DrClap wrote:
    From the API documentation for SimpleDateFormat:
    "Text can be quoted using single quotes (') to avoid interpretation."
    So your format should be:"yyyy-MM-dd'T'kk:mm:ss.SSz"(Note that I added the "z" at the end to handle the timezone part of your input.)From the description of the OPs problem - that of obtaining the "date" information from an XML file - it seems easier to remove the unwanted characters than to add single quotes where needed.

  • Date Format Validation

    Hi all,
    In one of my web dynpro's I set the date format to yyyyMMdd. When i push a button there's automatic validation of the date and he complains about the format: The error message i get is: Enter the value in the format 19871125 and my entered date is 20070827 ...
    When i select the date from the date picker, he puts it in the correct format, but the validation keeps failing. When i set format to yyyy.MM.dd for example, the validation does not fail.. Is this some kind of bug or is there a logical explanation for this?
    Kind regards,
    J.

    Hi,
    I'm setting the format programatically...
    When i check locale in web dynpro content it says the following about the current session:
    Current locale: en
    Default VM locale: en_US
    Kind regards,
    J.

  • URGENT: Date format in Reports Giving me trouble...plz help me out

    Hi guru's Can any one help me out
    I
    n the front end apps we are getting the date value as
    BOM_SRS_DATETIME_STANDARD
    Where we are entering the date value as MM/DD/RRRR HH24:MI:SS
    The date format set in the company is like RRRR/MM/DD HH24:MI:SS
    SO I format masked the date parameter in .RDF to RRRR/MM/DD HH24:MI:SS format.
    While the actual date format in the data base is like DD/MM/RRRR HH24:MI:SS.
    I checked all the old reports and the date format is like they masked the date format to company format and used the afterparameter trigger like bellow:
    if :P_SENT_DATE_FROM is not null and :P_SENT_DATE_TO is null then
    :P_SENT_DATE_TO := :P_SENT_DATE_FROM;
    end if;
    if (:P_SENT_DATE_FROM = :P_SENT_DATE_TO) and (:P_SENT_DATE_FROM is not null) then
    :WHERE_SQL := :WHERE_SQL || ' AND CREATION_DATE = '||' to_date('''||:P_SENT_DATE_FROM||''''||','||'''DD-MON-RR'')';
    else
    if :P_SENT_DATE_FROM is not null then
    :WHERE_SQL := :WHERE_SQL || ' AND CREATION_DATE >= '||' to_date('''||:P_SENT_DATE_FROM ||''''||','||'''DD-MON-RR'')';
    end if;
    if :P_SENT_DATE_TO is not null then
    :WHERE_SQL := :WHERE_SQL || ' AND CREATION_DATE <= '||' to_date('''||:P_SENT_DATE_TO ||''''||','||'''DD-MON-RR'')';
    end if;
    end if;
    I tried this but i couldnt get the output either.
    I am pretty much confused.
    Plz help me out...

    If you want to use a dynamic where caluse in your report query you can use a Reference Cursor using REF CUR QUERY tool in your report like this :
    function QR_1RefCurDS return DEF_CURSORS.CHARACT_REFCUR is
    temp_CHARACT DEF_CURSORS.CHARACT_refcur;
    begin
    IF :FROM_NO IS NULL AND :TO_NO IS NULL THEN
    open temp_CHARACT for SELECT ACCT_CODE, ACCT_NAME
    FROM CHARACT
    ORDER BY ACCT_CODE;     
    ELSIF :TO_NO IS NULL AND :FROM_NO IS NOT NULL THEN
    open temp_CHARACT for select ACCT_CODE, ACCT_NAME
    FROM CHARACT
    WHERE ACCT_CODE=:FROM_NO
    ORDER BY ACCT_CODE;     
    ELSIF :TO_NO IS NOT NULL AND :FROM_NO IS NOT NULL THEN
    open temp_CHARACT for select ACCT_CODE, ACCT_NAME
    FROM CHARACT
    WHERE ACCT_CODE BETWEEN :FROM_NO AND :TO_NO
    ORDER BY ACCT_CODE;               
    ELSIF :TO_NO IS NOT NULL AND :FROM_NO IS NULL THEN
    open temp_CHARACT for select ACCT_CODE, ACCT_NAME
    FROM CHARACT
    WHERE ACCT_CODE<=:TO_NO
    ORDER BY ACCT_CODE;     
    END IF;
    return temp_CHARACT;
    end;
    But first you have to declare a cursor type in a package

  • Converting time stamp in SECONDS to a calendar date format.. problems

    Hello. I'm trying to convert a long interger that represents the number of SECONDS passed since the 1970 date
    the number was originally generated by php's mktime() function
    one of the numbers I have for example is this : 1126933200
    I haven't done the math but this is a date probably around september of 2005.. it's irrelevant anyhow.
    I want to convert this to a date format I can use in java. I've tried to create a new date like so :
    Date date = new Date(1126933200);
    I've also tried it with the calendar method like so :
    Calendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(1126933200);
    it was only then that I realized that both these methods require the number of MILLI seconds. So I tried doing a simple multiplication by 1000 on my original number and then I started getting a "integer number too large" error when trying to compile.
    so i'm kind of at a loss here.. i figure I could make a function myself that would divide my number in days of 86400 seconds.. and then i'd have to keep in mind the bisectal (sp) and the months with more and less days etc.. but i'm sure there must be an easier way.
    and i don't get why a method who's meant to receive a very long number is giving me an error when i try to give one to it.
    your help is appreciated as always. thanks

    Hello. I'm trying to convert a long interger that
    represents the number of SECONDS passed since the
    1970 date
    the number was originally generated by php's mktime()
    function
    one of the numbers I have for example is this :
    1126933200
    I haven't done the math but this is a date probably
    around september of 2005.. it's irrelevant anyhow.
    I want to convert this to a date format I can use in
    java. I've tried to create a new date like so :
    Date date = new Date(1126933200);
    I've also tried it with the calendar method like so
    Calendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(1126933200);
    it was only then that I realized that both these
    methods require the number of MILLI seconds. So I
    tried doing a simple multiplication by 1000 on my
    original number and then I started getting a "integer
    number too large" error when trying to compile.So you needed to add L to one of the numbers.
    Note you also need to define what timezone that seconds number represents.
    With Gregorian it is going to use the local timezone (the code here will anyways). The code using Date is using the UTC timezone.

  • ( Urgent ) Date Formatting

    I want to know how to get a date value with Milliseconds by using Date Format or any.
    For Eg: I am having a LOG( Transactions) table wherein I have a date_create column of a DATE Datatype.
    I want to get( Display or retrieve) the value in Milliseconds after formatting. Is there anyway out.
    Does ORACLE provide that..
    Thanks in Advance for your Response..
    null

    2 solutions:
    1) write a java stored procedure. java has time functionality
    that is much more granular then the Oracle DATE type. This will
    work in 8.1.5 and up. It can look like this:
    [email protected]> CREATE or replace JAVA SOURCE
    2 NAMED "MyTimestamp"
    3 AS
    4 import java.lang.String;
    5 import java.sql.Timestamp;
    6
    7 public class MyTimestamp
    8 {
    9 public static String getTimestamp()
    10 {
    11 return (new
    12 Timestamp(System.currentTimeMillis())).toString();
    13 }
    14 };
    15 /
    Java created.
    [email protected]> create or replace function my_timestamp
    return varchar2
    2 AS LANGUAGE JAVA
    3 NAME 'MyTimestamp.getTimestamp() return java.lang.String';
    4 /
    Function created.
    [email protected]> l
    1* select my_timestamp, to_char(sysdate,'yyyy-mm-dd
    hh24:mi:ss') from dual
    [email protected]> /
    MY_TIMESTAMP
    TO_CHAR(SYSDATE,'YY
    2000-06-22 13:47:53.376
    2000-06-22 13:47:53
    [email protected]>
    2) use an external procedure written in C. C has api's to the
    system that allow for much more granular time components. This
    will work in 8.0 and up. For example if you run something like:
    [email protected]> create or replace library timelib as
    2 '/export/home/tkyte/src/t/extproc.so'
    3 /
    Library created.
    [email protected]> create or replace
    2 procedure get_extended_time( p_timestring out varchar2 )
    3 is external
    4 name "get_extended_time"
    5 library timelib
    6 language C
    7 with context
    8 parameters ( CONTEXT,
    9 p_timestring STRING,
    10 p_timestring INDICATOR short,
    11 p_timestring MAXLEN int,
    12 p_timestring LENGTH int );
    13
    14 /
    Procedure created.
    [email protected]> declare
    2 l_timestring varchar2(30);
    3 begin
    4 get_extended_time( l_timestring );
    5 dbms_output.put_line(
    to_char( sysdate, 'mm/dd/yy hh24:mi:ss' ) );
    6 dbms_output.put_line( l_timestring );
    7 end;
    8 /
    06/22/00 13:26:28
    06/22/00 13:26:28.103243
    PL/SQL procedure successfully completed.
    In sqlplus after compiling the following C code into a .so or
    .dll or .sl (depending on platform) you can get the
    milliseconds.
    Here is the C code:
    #include <stdio.h>
    #include <stdarg.h>
    #include <time.h>
    #ifndef OCI_ORACLE
    # include <oci.h>
    #endif
    #define raise_application_error return raise_application_error_x
    static long raise_application_error_x( OCIExtProcContext * ctx,
    int errCode,
    char * errMsg, ...)
    char msg[8192];
    va_list ap;
    va_start(ap,errMsg);
    vsprintf( msg, errMsg, ap );
    va_end(ap);
    OCIExtProcRaiseExcpWithMsg(ctx,errCode,msg,strlen(msg));
    return -1;
    long
    get_extended_time( OCIExtProcContext * ctx,
    char * p_data,
    short * p_data_i,
    int * p_data_maxl,
    int * p_data_l )
    struct timeval tp;
    if ( *p_data_maxl < 25 )
    raise_application_error( ctx, 20001,
    "String must be 25 bytes or more" );
    gettimeofday(&tp, NULL);
    cftime( p_data, "%D %T", &tp.tv_sec );
    sprintf( p_data+strlen(p_data), ".%d", tp.tv_usec );
    *p_data_l = strlen(p_data);
    *p_data_i = 0;
    return 0;
    null

  • Date Format  JSF problem

    what I am asking is ridiculous for most. anyways this is my code
    String pattern = "MM/dd/yyyy";
    String value ="11/12/1976"
         SimpleDateFormat sdf = new SimpleDateFormat(pattern);
         Date birthDate;
         Calendar todayDate;
         Date now = new Date();
         try {
              birthDate = sdf.parse(value);
              System.out.println("birthDate'''''''''' "+birthDate);
    for same reason "System.out.println("birthDate'''''''''' "+birthDate);"
    prints "Fri Nov 12 00:00:00 CST 1976"
    what do I have to do to make it print the same as 11/12/1976
    Thank you.

    for same reason "System.out.println("birthDate'''''''''' "+birthDate);"
    prints "Fri Nov 12 00:00:00 CST 1976"That's the default toString() representation of the Date object.
    what do I have to do to make it print the same as 11/12/1976Use SimpleDateFormat#format() to format a Date object into a human readable String representation.
    This has completely nothing to do with JSF by the way. In future please use 'New to Java' or maybe 'Java Programming' forums for those kind of basic API related questions.

  • Urgent: Date format conversion

    Hi
    I need to convert the date from 08/31/2006 to 31-Aug-06 format.
    Plz help me out.  Useful answers will be rewarded.  Thanks in advance.

    Hello,
    Check the table :
    T247
    Check these fm's
    Function Modules related to Date and Time Calculations
    DATE_COMPUTE_DAY  : Returns weekday for a date
    DATE_GET_WEEK  : Returns week for a date
    DAY_ATTRIBUTES_GET  : Returns attributes for a range of dates specified
    MONTHS_BETWEEN_TWO_DATES  : To get the number of months between the two dates.
    END_OF_MONTH_DETERMINE_2  : Determines the End of a Month.
    HR_HK_DIFF_BT_2_DATES  : Find the difference between two dates in years, months and days.
    FIMA_DAYS_AND_MONTHS_AND_YEARS  : Find the difference between two dates in years, months and days.
    MONTH_NAMES_GET  : Get the names of the month
    WEEK_GET_FIRST_DAY  : Get the first day of the week
    HRGPBS_HESA_DATE_FORMAT  : Format the date in dd/mm/yyyy format
    SD_CALC_DURATION_FROM_DATETIME  : Find the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE  : Find the time difference between two date/time
    HR_99S_INTERVAL_BETWEEN_DATES  : Difference between two dates in days, weeks, months
    LAST_DAY_OF_MONTHS  : Returns the last day of the month
    Vasanth

  • Acrobat 9.3.4 doesn't enforce Date Formating

    After we upgraded to Acrobat 9.3.4 from a previous version of 9.3 acrobat doesn't enforce date formating..before in a Text field formated as Date mm/dd/yyyy it would autocompelete if we typed in 9/21 to 9/21/2010.. now it doesn't, we can type any random text in the field and it isn't validated.
    Ideas?

    Just checked, its enabled.. when I say validate I'm referring to Acrobat's internal date format validation, not JavaScript.
    For example if you create a text box, goto properties, format tab, format category = date, date options mm/dd/yyyy
    now if you type:
    "abcdef" in that text box it should say, "Invalid Date/time: please ensure that the date/time exists.
    if you type 9/21 it will automatically turn it into 9/21/2010.
    After Appling the 9.3.4 update no such validation takes place, any value entered is accepted..

  • How to change Date format in Bex to DD/MM/YYYY

    Dear all,
    i have date settings as DD.MM.YYYY in user profile.but the Bex report is showing the date as MM/DD/YYYY. How can i change this to DD/MM/YYYY? If i have to write a customer exit then please advise ?
    Thanks in advance
    Regards
    Ravi

    Hi ravi
    look at these previous threads
    Date format change
    Problem in date format
    Regards
    NR

  • Generic Date Format

    Hi Folks,,
    I am using regex in my java code ..i need to specify the date as generic format...i tried with some cde ..i ned your suggestions whether is it correct..am i going in right path??
    Dated<space><DateFormat>
    Here is my java code:
    Matcher Assetdate=Pattern.compile(("Dated\\s*|\\d*/\\d*/\\d*|\\w*-\\d*-d*"),Pattern.CASE_INSENSITIVE).matcher(line1);
                while(Assetdate.find()){
                System.out.println(Assetdate.group());
                                        }Thanks.

    If you want to support all date formats valid in an XML document use XMLGregorianCalendar to parse dates:
    [http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/DatatypeFactory.html#newXMLGregorianCalendar(java.lang.String)]
    -Puce

  • URGENT !!!!   Problem with Date format MM/DD/YYYY in oracle database to BW

    Hi
    I am wondering if somebody can help me urgently.
    I have oracle database where date is of the format MM/DD/YYYY and I am loading data into BW. DATE data type
    Date in oracle database: 3/30/2007
    First when I used InfoObject ZDATE (with 0DATE) reference (DATS data type) data load failed saying that
    'Value '30-MAR-0 ' of characteristic 0DATE is not a number with 000008 spaces'
    Then I created ZDATE InfoObject as CHAR Type (Length 10) with PDATE Conversion Routine.
    when I created datasource using DB Connect and checked the contents using 'Display Table Contents' after creating data source the data field distorted as
    AR/-0/30-M
    After data load. when I checked PSA
    The Date records look same as AR/-0/30-M
    In cube the field appeared as  30-MAR-0  (last digit of year disappearing)
    In BEx report also it looks like 'AR/-0/30-M'
    Can somebody help me as quickly as possible.
    What should I do if i want to still use DATS data type for ZDATE?
    should I change date format in database if so to what?
    If I should use CHAR type with PDATE or any other routine can somebody give me the routine to have the date in the report exactly as it appears in database?
    I also tried changing date format in user profile...settings. But still its the same.
    Thanks in advance.

    Hello Snrella,
    You can solve this by converting the date format from oracle to the SAP internal date format  using an ABAP routine in the transfer rules.
    Assuming the oracle data field name is ZODATE then here's the ABAP you can use in the transfer rules. Create an ABAP routine transfer rule from ZODATE to your ZDATE infoobject, and then put this ABAP code there. (this code assumes that the format of the date from oracle is MM/DD/YYYY).
    concatenate tran_structure-/BIC/ZODATE+6(4) tran_structure-/BIC/ZODATE(2) tran_structure-/BIC/ZODATE+3(2) into result.
    Hope this helps.

Maybe you are looking for

  • My update says that its going to take 6 hours to install , is this normal?

    my update says that its going to take 6 hours to install , is this normal?

  • RDBMS event generator & JNDI datasources

    Hi everyone, My WLI 8.1 SP5 is going nuts ! I'm under a cluster architecture, WL 8.1 SP6 with Red Hat Linux, JRockit 1.4.2_10. Deploying an application i need to create some RDBMS event generator, but when i do this, i get an NameNotFoundException lo

  • I want to Prevent a specific URL through My Computer

    I want to Prevent a specific URL through My Computer.No one can access any specific URL which i Block. e.g http://www.yahoo.com i want to block this specific site.Plz help me to block this site.

  • InDesign CC Probleme mit Tags

    Guten Tag zusammen, Ich habe vor kurzer Zeit eine neue Stelle angefangen und arbeite seit dem mit einem neuen System - Tags. Die Daten werden automatisch aus einem externen Kundenverzeichnis geladen und über Tags in InDesign CC eingebunden. Wir haben

  • Is Spry wdiget causing my Dreamweaver CS3 to crash?

    Recently my dreamweaver cs3 crashed, The last thing I was doing on dreamweaver CS3 was using the spry tabs widget. When I tried to run Dreamweaver CS3 application, it would crash. I then had to reinstall my Dreamweaver following the clean cs3 routine