Validate date ?

Dear All,
May I enquire how to validate date for:
textDateofLoss.getText()
Is it:
if isDate(textDateofLoss.getText()){
//True date
else{
//False date}
Please advise.

Sorry, have to use the following:
import java.util.*;
import java.text.*;
public class validateDate {
public static void main(String args[]) {
String dt = "10-10-1990";
String format = "dd-mm-yyyy";
// String dt = "1990-10/10" throws a ParseException
// String dt = "1990-10-35" throws a IllegalArgumentException
try {
//DateFormat df =
//DateFormat.getDateInstance(DateFormat.SHORT);
SimpleDateFormat df = new SimpleDateFormat(format);
df.setLenient(false); // this is important!
Date dt2 = df.parse(dt);
System.out.println("Date is ok = " + dt2);
catch (ParseException e) {
System.out.println(e.getMessage());
catch (IllegalArgumentException e) {
System.out.println("Invalid date");
}

Similar Messages

  • Getting error while tring to Check in any document in Sharepoint 2007. Error - "Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) ...

    Hi Team,
    I am getting error while tring to Check in any document in Sharepoint 2007. Error - "Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength).
    Anybody please let me know how to resolve the issue. It has affected our 9 site collection with almost 2000+ sites. Please email me your your suggestion or you can share your ideas here also.
    Tried to reset the IIS, checked the Internet connection speed (8MBps). Cleared the cache and all but no luck.
    Thanks,
    Pronob

    Hello,
    I have found this support window for you:
    http://support.microsoft.com/kb/556031
    http://technet.microsoft.com/en-in/library/cc298582%28v=office.12%29.aspx
    This may help you
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to validate Date

    Hi,
    We have a date field in the form. I am validating date format as YYYY-MM-DD, validation works fine. But If user enters invalid date, how to validate date? For examples:
    2006-02-31 It is an invalid date. How can i validate it.
    If anybody have sample code, it will help me a lot.
    thanks
    Neopal.

    Hi Neopal,
    You can use something like the following to test the date is valid, use the validation event on the <Field> which you want to validate to call a Rule something like this (not complete)..
      <Rule name='isDateValid'>
            <RuleArgument name='date'/>
            <block>
           <script>
              var dateToTest = env.get('date');
              var formatter = new java.text.SimpleDateFormat('YYYY-MM-DD');
              Date validDate = formatter.parse(dateToTest);

  • Function Module to validate date

    Hi,
    Is there a Function module to validate date in transfer rules or update rules. I checked the forum, couldn't find an answer. Any help is appreciated
    Thanks
    Bala

    You should be able to use this FM:
    CALL FUNCTION 'RSAR_DATE_CHECK_PLAUSIBILITY'
      EXPORTING
        i_date                          = yourdate
    EXCEPTIONS
       PLAUSIBILITY_CHECK_FAILED       = 1

  • Validate Date Range in inputDate component

    Hi
    I am using JDev 11.1.1.2.0
    I have an inputDate component which on click i need to give dates from today to future dates not passed dates.
    So i have included 'validate date time range' component in the inputDate component and in the minimum property i have declared 'adf.currentDate' using expression builder and set the maximum as Jan 31,2099.
    But when i execute my application i am able to select passed dates using the inputDate component, please help how can i check the date using a validator in inputDate component.
    Thanks
    Sudeep

    ya i had tried with that property too....
    i have declared minValue as adf.currentDate and on that it changes the value of maxValue to current date in Jan 3,2012
    i have convertDatetime component in my inputDate to display the selected date in certain format.
    It gives error as the format doesnot matches with the convertDatetime and inputDate component.
    How can i use the minValue and maxValue of inputDate component?
    the component:-
    <af:inputDate
    label="Planned Termination Date"
    id="id2"
    value="#{modifyuser.pterminationdate}"
    valueChangeListener="#{modifyuserfields.plannedTermDate}"
    minValue="adf.currentDate" maxValue="2099-12-31">
    <af:convertDateTime pattern="dd-MMM-yyyy"/>
    </af:inputDate>

  • Validate date using RE

    Hey guys,
    Need to validate date using RE in format MM/DD/YYYY and optional HH:MM:SS
    I already have simple solution, but would like to add checks for leap year and dates like 02/30/2006 or 04/31/2006
    So far I have this:
    private static final String datePattern =
         "^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d" +
         "(\\s(([0-1]?[0-9]|2[0-3]):([0-5]?[0-9]):([0-5]?[0-9]))){0,1}$";

    A much better way is to specify the format of the data and parse it using the SimpleDateFormat class method parse.

  • Validate date of Birth

    How I can validate date of birth?
    Month-Date-Year
    Example: 11-21-1960
    Thanks

    You could use a regular expression:
    E.g.
    var dateRegExp = "^(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])-(19|20)\d\d$"; // mm-dd-yyyy
    if (oField.rawValue.search(dateRegExp) === -1) {
         // error!
    Or you could use a date object as suggested in the previous post, but also stop the user from typing in a date so they will be forced to use the date selection box. This would ensure that the date is always in the correct format. To stop the user from typing in data, put the following code in the change event for the field:
    if (xfa.event.change.length == 1) {
    xfa.event.change = "";

  • Validate Date and block JavaScript page change

    how I can validate date acrobat, can block JavaScript page change, only change with a button? 

    If you use the "util.scand" method date validation is part of the process. It either returns the number of milliseconds from the Epoch date used by JavaScript for the date time object the null value.
    Date Arithmetic has some sample scripts, but you need to keep in mind that Date and Time are not independent and using "new Date()" returns the date and time at the time that line of code is executed and that can cause issues for the computing of dates only.
    Are you sure of day count, most differences include the start and end dates in the number of days for the calculation.
    Custom calculation for today's date field (format is None):
    // get today's date an time
    var oToday = new Date();
    // set to start of day
    oToday.setFullYear(oToday.getFullYear(), oToday.getMonth(), oToday.getDate(), 0, 0, 0, 0)
    // set field value
    event.value = util.printd("d/mm/yyyy", oToday);
    Custom calculation for the difference in days field (format None):
    var cEnteredDate = this.getField("EnteredDate").value;
    var cToday = this.getField("Today").value;
    event.value = "";
    if(cEnteredDate != "" && cToday != "") {
    // process only if date values not empty
    // convert date strings to date time objectat midnight
    var oEnteredDate = util.scand("d/mm/yyyy", cEnteredDate );
    if (oEnteredDate == null) {
    app.alert("Error in processing entered date", 2, 0);
    oEnteredDate.setFullYear(oEnteredDate.getFullYear(), oEnteredDate.getMonth(),oEnteredDate.getDate(), 0, 0, 0, 0) 
    var oToday = util.scand("d/mm/yyyy", cToday);
    if(oToday ==  null) {
    app.alert("Error converting today", 2,0);
    oToday.setFullYear(oToday.getFullYear(), oToday.getMonth(),oToday.getDate(), 0, 0, 0, 0) 
    // convert date objects to days
    var nEnteredDate = Math.floor(oEnteredDate.getTime() / (1000 * 60 * 60 * 24));
    var nToday = Math.floor(oToday.getTime() / (1000 * 60 * 60 * 24));
    // compute & format the difference
    event.value = util.printf("%,0 1.0f", (nToday - nEnteredDate));

  • [BPC 7.5] or [BPC 10] Validate data from different periods

    Hi,
    is it possible to use the standard validation business rule to validate data in different periods? I need a rule that validates the total in my flow dimension from last year end to the value in the opening flow in the current period. Is that possible?
    Thanks,
    Arnold

    Hi Arnold,
    I do not think this is possible. You can only compare accounts and flows in the detailed rules. In the Header rules you can specify specific dimensions and time periods.
    You can maybe use script logic to write data to the current month into a validation test account from the last year into the current period and then run the validation rules.
    Thanks,
    John

  • RegEx to validate date between 1900 & today

    Hi,
    I have a RegEx which validates the date of birth
    (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)dd
    But I want it to validate date of birth until today only from 1900
    How can I do that using regular expression?
    a®s
    Edited by: a®s on Jul 2, 2008 3:00 PM

    Thanks for your reply Jan.
    Jan Stallkamp wrote:
    > In general regex tend to be easy to write but hard to read. So from a maintance perspective they might not be the best choice. >
    I accept the fact that you mentioned above.
    I am planning different RegEx for different date formats.
    This application need to be called from a PHP page. so don't find any other way to tackle this issue.
    Any other info?

  • Exit to validate data in CJ01

    Hi experts ,
    I have a issue in Exits . I need to validate data in CJ01 Project Definition data .
    Exactly is there any Badi or Userexit to validate the data at SAVE of the CJ01.
    Regards,
    Sandeep thota.

    Thats a very generic question. You can use various methods for that
    1. Use script task and include your validation logic
    2. Use derived column transform and do validation using ssis functions and return boolean result based on outcome
    3. Get details onto staging table, use t-sql stored procedure etc
    If you can explain exact scenario we may be able to suggest more specific answer.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • User exit, badi or enhancement to validate data before saving for  qm02

    Hi,
    Currently, I have a requirement to validate the data of a notification before saving data in Tcode qm02.
    I have found an user exit to check data for tcode qm02. It works for task tab, I mean I can get the data under task tab of qm02 and do the validation. However, for the tab processing: I want to validate the partner name before saving but I can not get the list of partners which is in Processing tab.
    Please let me know if you could show me the user exit, enhancement, or Badi so that I can validate the data under processing tab in qm02.
    Thanks in advance,
    Hung To

    Hi Keshav.T,
    Currently I am using this exit to validate data for the tab "Task". However, for the tab "Processing" I can not get the data, let say Partner, to validate.
    Thanks,
    Hung To

  • How can I validate data after writing and over reboot/powercycle?

    Hi,
    How can I validate data after writes are done? How can I validate data after reboot or powercycle of the machine is done?
    What are the options I should give while running vdbench? When should I use -v, -vq, -vt, -v -j, -vq -j, -vq -jr, -v -jr options?

    Please look for the "Data Validation and Journaling' chapter in the documentation.
    Henk.

  • Validate Data in Web Form

    we want to validate data in web form in planning through Java Script Code ?
    how we can do it and what is the location of that Java Script file ?
    One more thing ... if we make any changes in Java Script code then is it necessary to stop and start planning server or application ?
    Thanks in Advance ..... :-)

    Hi,
    you can resolve this problem, adding a JavaScript code in validateData.js.
    For example you can change and/or insert the code in validateForm function, that save the data only if the function return true.
    There are also another function and the code example in SampleValidateData.js that you can see.
    You find the ValidateData.js in the folder "custom" of your installation.
    For example:
    /default web application directory/deployments/your web server/HyperionPlanning/webapps/HyperionPlanning/custom
    I report an example for control the data before saving it:
    function validateForm(){
    if (equalsIgnoreCase(applicationName,"BDG"))
    if (equalsIgnoreCase(formName,"1.10A ECO"))
    var rowPrecVers = currentDataGrid.endRow;
    var colPrecVers = 2;
    var rowActVers = 3;
    var colActVers = 3;
    var valTotPrecVers = 0;
    var valTotActVers = 0;
    valTotPrecVers = currentDataGrid.fullPrecision[rowPrecVers][colPrecVers];
    for(rowActVers; rowActVers < currentDataGrid.endRow; rowActVers++){
    valTotActVers = valTotActVers + parseFloat(currentDataGrid.fullPrecision[rowActVers][colActVers]);
    if(valTotPrecVers < valTotActVers){
    alert("Ops!!!Don't match" + "\n"
    + "Previous Version: " + valTotPrecVers + "\n"
    + "Actual Version: " + valTotActVers);
    valid = false;
    return valid;
    else{
    return valid;
    Insert and modify this code in validateForm function.
    If in your installation use Tomcat web server, you must save the change on the ValidateData.js file each time. If you use the WebLogic web server tou must restart the service. For other web server I don't know.
    Take it easy and have fun!!!
    Flavio

  • Need help! Can't validate date overlaps for a tabular column

    Hello all,
    The validation I created to validate whether new or updates rows does not overlap with any records in the table isn't working.
    The columns are StartDt and EndDt
    Validation Type: NOT EXISTS
    Validation expresion:
    select 1
        from  sample S
        WHERE S.STARTDT BETWEEN :STARTDT AND :ENDDT
    OR(S.ENDDT BETWEEN :STARTDT AND :ENDDT)
    or (S.STARTDT <= :STARTDT and S.ENDDT >= :ENDDT)
    or (:STARTDT <= S.STARTDT and :ENDDT >= S.ENDDT)
    Error Message:
    Times overlap
    When Buttons pressed
    -Select Button-
    The validation works if a new row or updated row overlaps any existing start and end date records but it doesn't work if I update startdate and end date rows that doesn't overlap existing date times
    Example:
    TABLE DISPLAYS THE FOLLOWING RECORDS
    NAME                   START DATE                      END DATE
    TEST                    1/1/2012                               12/31/2012
    If I update the rows to the following values, I receive an error message (although those values don't overlap any records in the table)
    NAME                   START DATE                      END DATE
    TEST                    6/1/2012                               10/30/2012
    Any ideas? Do I need to change my code?
    Click the link to view the answer to this question. Need help! Can't validate date overlaps for a tabular column
    Message was edited by: CharlieMack

    Logic for date range overlap testing only requires two conditions in the WHERE clause:
    ORACLE-BASE - Overlapping Date Ranges
    WHERE S.STARTDT <= :ENDDT AND S.ENDDT >= :STARTDT -- TRUE for ranges that overlap
    It looks a little odd, but, if you scribble out a 'logic table', it makes sense.
    Condition
    A.start <= B.end
    A.end >= B.start
    A__A B--B
    true
    false
    A__B=A--B
    true
    true
    A__B==B__A
    true
    true
    B--A==B__A
    true
    true
    B--B A__A
    false
    true
    MK

Maybe you are looking for