How to validate the date in my class

Hi
In my project with jsp and struts I need to validate the date field.
So in the action class I want to validate the date that is the date is in dd/mm/year format?
can anybody please give some idea to do this?
Thank you so much.

Here is a method that validates day/month/year using the Calendar class.
     public boolean validateDate(int day, int month, int year) {
          try {
               Calendar cal = Calendar.getInstance();
               cal.clear();
               cal.setLenient(false);
               cal.set(year, month-1, day);
               // need to call getTime() to make the calendar compute/validate the date
               cal.getTime();
               return true;
          catch (IllegalArgumentException e) {               
               return false;
     }

Similar Messages

  • How to validate the dates in the table control ?

    How to validate the dates in the table control ?
    Can I write like this ?
    LOOP AT it_tab .
    CHAIN.
    FIELD : it_tab-strtdat,it_tab-enddat.
    module date_validation.
    ENDCHAIN.
    ENDLOOP.
    Module Date_validation.
    ranges : vdat type sy-datum.
    vdat-sign = 'I'.
    VDAT-LOW = it_tab-STRTDAT.
    VDAT-HIGH = it_tab-ENDDAT.
    VDAT-OPTION = 'BT'.
    APPEND VDAT.
    WHAT CODE I have to write here to validate ?
    and If I write like this How can we know which is the current row being add ?
    It loops total internal table ..?
    Bye,
    Muttu.

    Hi,
    I think there is no need to put chain endchain.
    To do validation you have to write module in PAI which does required validations.
    Thanks
    DARSHAN PATEL

  • How to validate the data in the table

    Hi Experts,
    My question is
    I am having a table control on my view. I need to validate the data entered by the user on the table
    and after validation i need to save the data into database table.
    Now my question is only related to Data Validation on table UI element.
    If the user enters 3 rows and if the 2nd and 3rd row are already existing,
    It should throw the message Entry already exists and the pointer should
    be at Row number 2 in this case.
    Similarly in the 2nd row i have a date field and if the user enters some character
    then it should throw an error message that Numeric values are only allowed and
    the pointer is placed in the 2nd row Date column so that it allows user to modify
    the wrong entry.
    Please advise.
    Regards,
    Chitrasen

    Hi,
    for validating user input in table , you have to get the entries inserted by user into an internal table using get_static_attribute_table and futher have your check using loop endloop.
    For date field, make the context attribute binded to date column as DATS. This would make sure the user inputs a valid date without your custom code.

  • How to validate the date in alv List

    Hi,
    How to write the code for date validation in alv.
    for ex
    i have to recieve the data in between any two months such as
    jan- feb,
    june-july,
    aug-sep,
    nov-dec,
    dec-jan,
    Could you plse explain me with some examples
    Thanking you
    Ravi Kumar

    I did not understand your requirement fully...but this code will give you date range for any two months..
    depending up on date you've supplied...
    DATA : date LIKE sy-datum,
           date_low LIKE sy-datum,
           date_high LIKE sy-datum.
    date = sy-datum.
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
      EXPORTING
        months  = '-1'
        olddate = date
      IMPORTING
        newdate = date_low.
    date_low+6(2) = '01'.
    CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
      EXPORTING
        day_in            = date
      IMPORTING
        last_day_of_month = date_high.
    WRITE :/ date_low.
    WRITE :/ date_high.

  • How to validate the field when i am populating the data cursor to block

    Hi,
    I am populating data cursor to multi record block.
    Block contain 5 items. I am populating data cursor to block for 4 items. User will enter one item value that is quantity field.
    If user enter negative values and decimal points in quantity filed i need to display message to user item level.
    Please do the needful how to do it.

    902434 wrote:
    Hi,
    I am populating data cursor to multi record block.
    Block contain 5 items. I am populating data cursor to block for 4 items. User will enter one item value that is quantity field.
    If user enter negative values and decimal points in quantity filed i need to display message to user item level.
    Please do the needful how to do it.If you want to validate at entry level then use When-Validate-Item trigger and check the input and show message. Like
    If :quentity <0 then
    message('do not enter negative value');
    message('do not enter negative value');
    raise form_trigger_failure;
    end if;Why u open same thread again ? not closing one.. check this one
    </a>
    How to validate the field when i am populating the data cursor to block
    Hopes this helps
    If someone's response is helpful or correct, please mark it accordingly.

  • How do u validate the data

    Hi
    I want to know Validate the data after extracting from R/3 to BW. Can any one of u please help me how should i go about this..
    If the annswers were given step by step briefly the full points wil be rewarded....
    waiting for the answrs

    Hi Kiran,
    Reconcilation:
    Reconcilation is the process of comparing the data after it is transferred to the BW system with the source system. The procedure to do reconcilation is either you can check the data from the SE16 if the data is coming from a particular table only or if the datasource is any std datasource then the data is coming from the many tables in that scenario what I used to do ask the R/3 consultant to report on that particular selections and used to get the data in the excel sheet and then used to reconcile with the data in BW . If you are familiar with the reports of R/3 then you are good to go meaning you need not be dependant on the R/3 consultant ( its better to know which reports to run to check the data ).
    I will give you a scenario to help you understand it better. Lets say BW extracts FI data from R/3. To make sure that all the records has been extracted from R/3 we can create a report in R/3 which will show the year-to-date balance of all the documents posted and we can create a BEx query on the BW cube which will also display the trial balnce. Any difference between the two balance will identify the records missing from R/3.
    Similary you can model other scenarios as per your requirement. If you are extracting from 2 or more different sources from R/3 then create a multicube on top of the individual cube and produce the report. You need to also create a similar report in R/3 as well.
    check this How to Doc:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a5ee147-0501-0010-0a9d-f7abcba36b14
    Pls do check the link's below
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a5ee147-0501-0010-0a9d-f7abcba36b14
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/how%20to%20validate%20infocube%20data%20by%20comparing%20it%20with%20psa%20data
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/8c92d590-0201-0010-5aa0-ee7a993f295c
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/968dab90-0201-0010-c093-9d2a326969f1
    Question regarding Tranports?
    ****Assign Points If Helpful****
    Regards,
    Ravikanth

  • How to read the data in excel sheet

    Dear sir,
    How to read the data in excel sheet when i recieve a data serial communication... ie i have store a data in excel such that
    Cell A       Cell B
       A           Apple 
       B           Ball
       C           Cat
       D           Doll
    when i recieve A from serial communication i have to display Apple, and when i recieve B i have to display Ball and so on.. 

    Hi, 
    I would recommend you to have a look at the VI attached. It makes use of a VI named 'Read from Spreadsheet' to read the row and column data from the tab delimited excel file. The read data is then searched for the Alphabet specified and finally returns you the corresponding string. The test file used to validate the operation of the VI is also attached. 
    Trust this would help you solve the issue. 
    Regards, 
    Sagar G Yadav | Application Engineer | National Instruments
    Attachments:
    read_from_excel.vi ‏10 KB
    Book1.txt ‏1 KB

  • How to change the date format?

    Hi,
    I need to display the data format as(YYYY-MM-DD). But now it displays(2009-1-9)
    Here is my code snippet which i used to display the data format as(2009-1-9)
    *<INPUT TYPE=TEXT NAME="date_submitted" MAXLENGTH=20 SIZE=10 VALUE="" onBlur= "return dateSubmitted()">  (YYYY-MM-DD)*
    *<SCRIPT LANGUAGE="javascript">*
    dateSubmitted()
    *</SCRIPT>*
    function dateSubmitted()
                        if (document.pgUpdate.date_submitted.value == "")
                             date = new Date();     
                             month = date.getMonth() + 1     
                             document.pgUpdate.date_submitted.value =
                                            date.getYear() + "-" + month + "-" + date.getDate();
                        return true;
    Can anybody help me how to change the date format?
    Thanks in advance!

    prit123 wrote:
    use SimpleDateFormat class. The code is :He posted a Javascript related question, not a Java related question.
    Please use forums devoted to Javascript. You're here at a Java/JSP forum.
    There are JS forums at webdeveloper.com and dynamicdrive.com. Good luck.
    String formatPattern = "yyyy-mm-dd";
    SimpleDateFormat sdf = new SimpleDateFormat(formatPattern);
    sdf.format(yourdate);yyyy-mm-dd denotes year-minutes-days. Please go read the SimpleDateFormat API as well.

  • How to store the data of a file into an ArrayList?

    Hi! everyone.
    I want to know
    if I have a File, and the data in the file are type int, type String...
    And I have a ArrayList which is of type Question
    How do I store the data of that file into the ArrayList
    I tried to use the while loop(use the hasNextLine() to read the data line by line)
    But I cannot add data which are not of type Question to the ArrayList.
    Can you tell me what I should do, please?
    I also wonder that
    The data of the file are of many types, but when I try to read it with the nextLine(), the data all turn out to be of type String. Why?
    Thank you.
    Edited by: Terry001 on Apr 30, 2008 1:13 PM

    No, a line in the file is just part of a question
    The format of the file is like this:
    *<question type code>                    :     String*
    *<question point value>                    :     int*
    *<question category>                         :     String*
    *<question difficulty level>               :     int*
    *<question text>                              :     String*
    *<question correct answer>               :     String*
    *<optional question-specific data>     :     String*
    *<question terminator>                    :     String*
    And here is an example
    TF //TrueFalseQuestion
    5 //points value
    None //category
    3 //difficulty level
    The capital of the United States is Washington, D.C. //question text
    True // answer
    *** //quetion terminator
    I created an ArrayList in the Test class:
    private ArrayList<Question> questions; // Create inside constructor
        public Test (String name, String instr)
            testName = name;
            scoreEarned = 0;
            scorePossible = 0;
            instructions = instr;
            questions = new ArrayList<Question>(); //[MAX_NUMBER_OF_QUESTIONS];
        }And I tried to use the following method to store the data of the file to the ArrayList
    // This method loads a set of questions from a plain text file
        public void loadQuestionsFromFile(String fileName) throws FileNotFoundException
            try
                File fileReader = new File("input.txt");
                Scanner sc = new Scanner(fileReader);
                while (sc.hasNextLine())
                    // I don't know how to pass the data I got from the nextLine() method to the ArrayList because they are of different type
            catch (FileNotFoundException a)
                System.out.println(a);
        }    As all you said, I should create an Question object in the while loop
    Question temp = new Question ();But I have no idea how to pass the int and String to the Question object.
    Thank you

  • How to change the date path of Web Server to my system time?

    Hi,
    I have downloaded a Countdown SWF file from the Internet. It is working fine with the Computers which have Internet Connection. But not working without Internet connection because of the following line of code in XML file:
    <PHPurl>http://www.flepstudio.org/utilita/CountDown/gettime.php</PHPurl>
    When I opened the webpage using the above code, it shows time in a typical digits:
    Monday, October 18, 2010 9:12:52 PM in my System -shows in Web browser like : time=1287425579
    How to modify the code so that I can use my System time to work with Countdown without Internet Connection.
    The following is the path from where I have downloaded the Countdown file:
    http://www.flepstudio.org/forum/flepstudio-utilities/2960-flash-cs3-countdown.html
    Please help me to run this countdown without internet access.
    Thanks.

    It appears all that php file does is return a time=value variable.  So you need to see where that time variable is implemented in the Flash file and assign it a value using the Date.getTime() method instead of having the PHP file get called into play.  Look in the help documents or Google if you do not know how to use the Date class.

  • How to validate the file path when downloading.

    Hi
    How to validate the file path when downloading to Presentation or application Server.

    hiii
    you can validate file path by following way
    REPORT zvalidate.
    TYPE-POOLS: abap.
    DATA: w_direc TYPE string.
    DATA: w_bool TYPE abap_bool.
    w_dir = 'c:\Myfolder\'.
    CALL METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
    directory = w_direc
    RECEIVING
    result = w_bool
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    wrong_parameter = 3
    not_supported_by_gui = 4
    OTHERS = 5.
    IF NOT w_bool IS INITIAL.
    WRITE:/ 'Directory exists.'.
    ELSE.
    WRITE:/ 'Directory does not exist.'.
    ENDIF.
    regards
    twinkal

  • How to validate a date in message mapping

    Hi experts,
                    how to validate a date in message mapping. For ex:  if date comes as 2008/02/31, then file it shold not get processed.how to achieve this in message mapping. Please help .
    Thanks&Regards,
    Reyaz Hussain

    Hi,
    There are few simple ways for date validation as follow,
    1.If you would like to handle it in XI only, then in message mapping you could verify about it with the help of generating smart exception.
    For e.g in mapping there is one Date conversion API i.e. somthing DateTransformation It converts the incoming date format to required format. Here give the date format i.e expected from Sender File.
    If in case the format miss-matched then it will create the exception.
    You could handle this exception with the use of [Alert notification|http://help.sap.com/saphelp_nw04/helpdata/en/2c/abb2e7ff6311d194c000a0c93033f7/frameset.htm] and could be even able to notify to sender system about it.
    2. The another solution is easy for SAP synchornous communication --If you are passing the file data to SAP, then you could use below function modules to verify date format in receiver RFC/BAPI or inbound IDOC program. If the sy-subrc is not 0 then don't process further.
    CONVERT_DATE_FORMAT
    ISU_DATE_FORMAT_CHECK
    Thanks
    Swarup

  • How to capture the data input in the input box like text box  on webpage?

    I would like to know how to use the data we key in in the textbox on the webpage and write it to database using JSP

    I would like to know how to use the data we key in in
    the textbox on the webpage and write it to database
    using JSPIf you want to store it into database....you'll need that
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:YourDSN");
    Statement stat = con.createStatement();
    String query = "INSERT INTO yourTable (Field) VALUES(TextBox value)";
    stat.executeQuery(query);
    con.close()
    Not tested but should work (depends also on your configuration)

  • How to Validate the Cube in Essbase

    Hi All,
    in Essbase How to Validate the ASO Cube. How can we validate the data is loaded correctly or not after data loading.
    please let me know how to do this job?
    Regards

    If you load data you can see the data load successful and the no of cells updated in the dialogue box.
    If there any records rejected they are thrown into dataload .err file.
    If you want to validate the input data you can verify the input records in the excel add-in.
    If you want validate the business logic ( ie data at the high level ) you have to write SQL Procedures or Custom programs at the Source layer to calculate the high level data in ESSBASE and compare the results in essbase Roll UP Using Excel add-in.

  • How to validate when date format is diff Internally and externally

    Hello,
    How can I validate the Date format if Internal format and external format is different.
    Ex :
    *  SELECT SINGLE CRTSP
    **                FROM /SAPSLL/PR
    **                INTO L_CRTSP
    **                WHERE CRTSP IN S_CRTSP .
    CRTSP (YYYY/DD/MM HHMMSEC) Internal Format
    S_CRTSP (YYYY/DD/MM) External format - selection option
    I had done following to convert the internal format to external format.
    DATA : LV_DT TYPE STRING.
    DATA :  L_CRTSP TYPE /SAPSLL/CRTSP.
    SELECT SINGLE CRTSP
                    FROM /SAPSLL/PR
                    INTO L_CRTSP.
    MOVE : L_CRTSP TO LV_DT. "(YYYY/DD/MM HHMMSEC)
    L_LEN = STRLEN( LV_DT ).
    L_DATE = LV_DT+0(8).
    I have the date format that i need in L_DATE."  (YYYY/DD/MM)
    Now how should I validate?
    *  SELECT SINGLE CRTSP
    **                FROM /SAPSLL/PR
    **                INTO L_CRTSP
    **                WHERE CRTSP IN S_CRTSP .
    Please let me know how can I validate or how can I write the select query to validate this field.
    There should be some way using Wildcard or some function module...which I am not sure...
    Any suggestions will be appreciated!
    Regards,
    Kittu
    Edited by: Kittu on Jan 6, 2009 12:58 PM

    Hello,
    Thank you for youe response and I apprecaite the help so far.
    This logic work if it is Parameter...When I have select option it is not working as it is not taking the range values...
    SELECT GUID_PR "Primary Key as GUID in "RAW" Format
    CRTSP "PRODUCT CREATED ON
    CHTSP "PRODUCT CHANGED ON
    FROM /SAPSLL/PR
    INTO TABLE T_PR.
    DATA : T_PR1 TYPE TY_PR OCCURS 0 WITH HEADER LINE.
    DATA:  W_TEST    TYPE STRING,
           W_LV_LEN  TYPE I,
           W_LV_LEN1 TYPE I,
           W_LV_DATE(20)  TYPE C,
           W_LV_DATE1(20) TYPE C.
    DATA : W_V(8) TYPE C,
           S_CT(11) TYPE C.
    SORT T_PR BY CRTSP CHTSP.
    LOOP AT T_PR INTO WA_PR.
      W_TEST = WA_PR-CRTSP.
      W_LV_LEN = STRLEN( W_TEST ).
      W_LV_DATE = W_TEST+0(8).
    ** IF WE SELECT ONLY ONE DATE IN SELECT OPTION
    s_crtsp VALUE IS - IEQ20040101..bY REMOVING FIRST THRID DIGITS
    WE ARE GETTING THE S_CRTSP VALUE IS 20040101 AND THIS LOGIC IS WORKING FINE..
       MOVE S_CRTSP TO S_CT.
      W_LV_LEN1 = STRLEN( S_CT ).
      W_LV_DATE1 = S_CT+3(8).
    *  IF W_LV_DATE NE S_CRTSP
    IF W_LV_DATE NE W_LV_DATE1.
      W_FLG = 'X'.
        DELETE T_PR INDEX SY-TABIX.
      ENDIF.
      CLEAR W_FLG.
    ENDLOOP.
    Can we do anything for this...
    ANy suggestions would be apprecaited!
    Regards,
    Kittu

Maybe you are looking for

  • Recommendation: disk drive configuration

    I use my Mac Pro at work for some basic iMovie video editing, so I have very capacity requirements. I currently have multiple hard disks; my startup disk is a 500GB SATA in HDD bay 1. I have two 400GB SATA drives in HDD bays 2 & 3, RAIDed together wi

  • The installer disc could not be found bootcamp mountain lion

    Hi, Got a small problem when i'm trying to install Windows 7 (Downloaded from MSDN) Dual boot is giving me an error message 'the installer disc could not be found bootcamp mountain lion' I burned two DVD-r's 1. http://cl.ly/image/0u3M3m1m3V0B 2. http

  • Invoice report with BPChCODE and BPChName

    Hello Xperts I want to produce a report that will show Invoices by country and their BPChCODE and BPCh NAME In order to get the BPCh name, I have linked a second OCRD Table. but now the query gives me only the Invoices that has BPChCODE, I want to se

  • Finder Show Resolution Column in non Pictures folders

    This is really useful feature of mavericks. In list view when in the pictures folder you can add the column 'Resolution" Problem is most images are not in the Pictures folder,  How can I get it across all the folders? Maybe applescript? Terminal? Cha

  • Error message: $host does not have a method 'resetDataPermsCheck'

    LiveCycle Designer 8.05. I am trying to reset the data in a subform. It is working great in certain subforms in my form. However, some of the code is as follows: if (form1.P1.docSF.new_revision.rawValue == "0") { // do something } else { xfa.host.res