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.

Similar Messages

  • 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 validation in " DD-MON-YYYY"

    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.
    Edited by: Vaibss on Nov 25, 2008 2:09 AM
    Edited by: Vaibss on Nov 25, 2008 2:10 AM

    Hello,
    Duplicate post -
    Date validation in "DD-MON-YYYY" Format,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • 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

  • 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

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

  • Data Validation in Excel used in Format Range

    Hi Experts,
    Im just wondering if there's a way i can use format range to carry out the data validation of excel.
    i mean, i need to limit the users to enter only numberic data to the input cells, hence they cannot input any letter and negative values.
    i tried applying the data validation in format range but, its not spreading the data validation.
    if i apply data validation to every cell, when i expand, the data validation disappears.
    Any advise.
    Thanks much as always...

    Hi,
    I was not able to use Data Validation in FORMAT RANGE.
    If you want to apply this data validation for the whole data range, you can apply this data validation in the first cell of the first row,first column of evdre. It will apply to the whole data range.
    If you want to apply this for certain columns, its a bit tricky.
    You must break your columnKeyRange into 2 and insert a column in between. In the 1st columnkeyrange, get the data, hide this column alone and add this column in getonlyrange. Next, in the newly inserted columns between the 2 column key ranges, you can use your Data Validation in 1st row. While expanding, it will automatically copy the data validation to the remaining rows. Now, In the second columnkeyrange, get the value based on the data validation cell, hide this column alone. So now you will have 3 columns, with those in the column key ranges as hidden ones and the one in between will be shown to the users.
    I know, this workaround is a bit tricky, but it works flawlessly. I have used this for umpteen sheets.
    Karthik AJ

  • Problems with date validation pattern DD.MM.YYYY in Form Builder

    (I am using LiveCycle Designer 8.0.)
    My form uses an input date field which consistst of DD.MM.YYYY.
    Display pattern, edit pattern, validation pattern and date pattern has been set to DD.MM.YYYY.
    "Validation Pattern Message"-box has been set to checked.
    "Validation Script Message"-box is not checked.
    1. When I type:      313101
    the system converts the digits to the date 01.01.3131
    2. When I type:      3131
    the system converts the digits to the date 01.01.3131
    3. When I type:       31   
    I get an error message "Date is not valid."
    I need a form to throw an error message if the user doesn`t type the correct input
    DD.MM.YYYY.  (01.03.2009)
    Thanks in advance.
    Tor

    Does anyone have any input on this matter?
    Thanks in advance.
    Regards,
    Tor

  • 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

  • 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

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

    Hi ,
    I have a created an 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.

    Hello,
    You have duplicated this post, see my answer here -
    Re: Date validation in "DD-MON-YYYY" Format,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • 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! :-)

  • Convert date in modal binding table into dd.mm.yyyy format

    DEar ALL,
    i have a date in the modal table, this value is coming from r/3 in yyyymmdd format. But i need to change its format to dd.mm.yyyy. How can i achieve it..i don't want to create my own table...pls suggest
    Regds,
    Anup.

    Hi Anup,
    Is the field that is coming from R/3 of type DATE?
    If yes then the conversion of the date should be automatic, and the display will be according to your locale, user language, browser language.
    You can set the format using
    String date = (new SimpleDateFormat("MM/dd/yyyy").format(new java.util.Date()));
    Hope this helps.
    Regards,
    Shubham

  • 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

Maybe you are looking for