validationrule for date as format yyyy-mm-dd in drools



Share on Google+Share on Google+

validationrule for date as format yyyy-mm-dd in drools
0 Answer(s)      5 years and 11 months ago
Posted in : Date-Calendar

Please give idea about this one..I have two textfield. User can select the date from calender or he can write the text to it.. when user enetr text we have to follow format yyyy-mm-dd: How i write the validation rule for date as a format yyyy-mm-dd. Please give sample code for this one. Its urgent

This is my bean class:

import java.text.SimpleDateFormat; import java.util.Date;

import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient;

@Entity @Table(name = "DATSTMPEPOUTOF_SERVICE")

public class StampOutOfService extends BaseDataEntryFormEntity {

   private Date outofServiceStartDate;
   private Date outofServiceEndDate;
   private int lineYear=20;

   SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd");

   @Column(name = "LINE_YEAR_FK", nullable = false)
   public int getlineYear() {
           return lineYear;
   public void setlineYear(int lineYear) {
           this.lineYear = lineYear;

   @Temporal (TemporalType.DATE)
   @Column (name = "START_OUT_OF_SERVICE",nullable = true)
   public Date getOutofServiceStartDate() {
           return outofServiceStartDate;
   public void setOutofServiceStartDate(Date outofServiceStartDate) {

           this.outofServiceStartDate = outofServiceStartDate;

   @Temporal (TemporalType.DATE)
   @Column (name = "END_OUT_OF_SERVICE",nullable = true)
   public Date getOutofServiceEndDate() {
           return outofServiceEndDate;
   public void setOutofServiceEndDate(Date outofServiceEndDate) {
           this.outofServiceEndDate = outofServiceEndDate;


my bean: for form creation:

                           <bean class=""   p:caption="Out of Service Start Date" />
                           <bean class="com.xxxx.xxxx.dataentry.DataEntryFormFieldDate"

p:type="DATE" p:entityMapping="outofServiceEndDate" p:caption="Out of Service End Date" />

           <property name="template">
                   <bean class="com.xxxx.xxxxx.dataentry.templates.HorizontalTableTemplate"

p:fixedColumns="1" />

Validation rule for date in drools:

rule "Stamping Out Of Service Start date should be valid date"

dialect "mvel"


droolsErrors : com.xxxx.xxxx.rules.beans.EntityErrors()

com.xxxx.xxxx.dataentry.beans.StampOutOfService (outofServiceStartDate !=null && outofServiceStartDate < df)

then droolsErrors.addError("outofServiceStartDate", "stmpOutOfServiceStartDateInvalid", "Please use the format yyyy-mm-dd");


View Answers

Related Tutorials/Questions & Answers:
validationrule for date as format yyyy-mm-dd in drools
validationrule for date as format yyyy-mm-dd in drools  Please give... format yyyy-mm-dd: How i write the validation rule for date as a format yyyy-mm-dd...("outofServiceStartDate", "stmpOutOfServiceStartDateInvalid", "Please use the format yyyy-mm-dd
php date format yyyy-mm-dd
php date format yyyy-mm-dd  date format yyyy-mm-dd validation
How to convert string to date in java in yyyy-mm-dd format?
How to convert string to date in java in yyyy-mm-dd format?  Hi, I have a date in yyyy-mm-dd format. How to convert string to date in java in yyyy... java.util.Date; /* * Example of formatting date in Java * from yyyy-mm-dd formaat
how to format date from yyyy-mm-dd to dd-mm-yyyy
how to format date from yyyy-mm-dd to dd-mm-yyyy  <!DOCTYPE html... to calculate the nos. of days between two dates, the date format is in "yyyy-mm-dd", so what i want is in "dd-mm-yyyy" format. So, how to change it? I would be much
get current date in java in yyyy mm dd hh mm ss format
get current date in java in yyyy mm dd hh mm ss format  Hi, I want to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program? Thanks  
Java convert string to date from format yyyy-mm-dd hh mm ss
Java convert string to date from format yyyy-mm-dd hh mm ss  Hi, I have date in the string yyyy-mm-dd hh mm ss format. Now I will want this string date into the date format. How to convert string to date from format yyyy-mm-dd
convert yyyy-mm-dd hh mm ss to date in sql
convert yyyy-mm-dd hh mm ss to date in sql  Hi, How to convert yyyy-mm-dd hh mm ss to date in sql? Thanks   Hi, You should use following code in SQL DATE_FORMAT(STR_TO_DATE(my_date, "%Y/%m/%d %H:%i:%s.%f"), "%Y-%m
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
Mysql Date Expression
a format  'YYYY-MM-DD' and 'HH.MM.SS'. Timestamp columns are displayed... Mysql Date Expression       The Tutorial illustrate an example from 'Mysql Date Expression
Mysql Date Type
' records in 'yyyy-mm-dd' format. select emp_dob from employee: The select query return the emp_dob  records in "yyyy-mm-dd" format. The Date Type...; Mysql Date Type is used to show the date in "yyyy-mm-dd" format.The
java format date
java format date  Hi, How can I format the date in the following pattern? yyyy-MM-dd   import java.util.*; import java.text.*; class...-MM-dd"); String formattedDate=sdf.format(date
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
String to Date format
SimpleDateFormat("yyyy-MM-dd"); String formattedDate=sdf.format(date...("yyyy-MM-dd"); String formattedDate=sdf.format(date...String to Date format  My Date format is String Eg(Jan 20 2011
date format - Java Beginners
date format  How to convert yyyy-mm-dd to dd-mmm-yyyy  Hi friend, Code to convert yyyy-mm-dd to dd-mmm-yyyy : import java.util.Date...(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd
Change Date Format - Development process
Change Date Format  Hi, While retrieving data frm database, date format displayed as yyyy/mm/dd but i want to display as dd/mm/yyyy. I have tried parse,format functions but not getting output. can u send me code
Validating date in javascript - Java Interview Questions
; In what format you are going to enter the date in Text box (i.e : dd/mm/yyyy or mm/dd/yyyy or yyyy/mm/dd...Validating date in javascript   Hi Deepak, Can u give
date format - JSP-Servlet
"; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date dateStr...); System.out.println("yyyy-MM-dd date is ==>"+formattedDate); Date...); System.out.println("dd-MMM-yyyy date is ==>"+formattedDate); } } Thanks
Java Date conversion - Date Calendar
Java Date conversion  How do I convert 'Mon Mar 28 00:00:00 IST 1983' which is a java.util.Date or String to yyyy/MM/dd date format in sql
date format - Date Calendar
date format  how to convert dd-mmm-yyyy date format to gregorian...="19-Sep-2008"; DateFormat format ; Date date ; format = new SimpleDateFormat("dd-MMM-yyyy"); date = (Date)format.parse(strDate); Calendar cal
Date format - Date Calendar
Date format  please convert dd-mmm-yy date format to gregorian calendar date format.  Hi friend, Code related your Problem: import...]); Calendar calendar = new GregorianCalendar(pdt); Date time = new Date
Date format - Date Calendar
); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy...Date format  Hi All, I am getting a date from database as a format... field.Every time i need to check the format of the date field and make sure the correct
Struts 2 Date Format Examples
in (yyyy-MM-dd) Format:</td> <td> <b><s:date name...; <tr> <td>Date in (dd-MMM-yyyy hh:mm AM/PM) Format:<...; <tr> <td>Date in (dd/MM/yyyy hh:mm) Format:</td>
struts2.2.1 date Format example
;Date Format(EEEE yyyy-MM-dd):</b><br/><br/> <s:date...; <b>Date Format (EEEE MM/dd/yyyy hh:mm AM/PM):</b><br/><.../yyyy 'at' hh:mm a" /> <hr> <b>Date Format (EEEE dd-MMM
php date format change
php date format change  How to change the date format in PHP
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
date_format() date_format alias DateTime::format function returns date formatted according to given format. It returns formatted date on success otherwise False on failure. Description on date_format() PHP public string DateTime::format
php date format validation
php date format validation  How to validate the date field in specific format in PHP
Simple date formatter example
into the "yyyy-MM-dd HH:mm:ss" format. formatter = new SimpleDateFormat... we have formatted the date into  "yyyy-MM-dd" format. Here... formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate
String to date with no format
date format can be (mm-dd-yyyy) if the 99th record also was 06-06-2006 the result should be date format can be (mm-dd-yyyy;dd-mm-yyyy) can sum1 please help me... into a date .. this is simple .. but i want to do it without knowing the date format
Date auto format
Date auto format  Hi, I have jsp page and Date field with input type. Requirement is, if we enter date as MMDDYY or MMDDYYYY and clicking the tab the date(MMDDYY or MMDDYYYY) have to auto format to MM/DD/YYYY. could you please
php date format am pm
php date format am pm  how to set the date format that will display the date in both am pm format


Advertisement null