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

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

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
c# current date in yyyy-MM-dd format
format. In c# how to get current date in yyyy-mm-dd format...(dateString ); Above code will give date into 2021-01-21 format (yyyy-MM-dd). I...c# current date in yyyy-MM-dd format  Hi, How to get the current
How to convert date to string in Java in yyyy-mm-dd format
to String in yyyy-mm-dd format. How to convert date to string in Java in yyyy... it to yyyy-mm-dd String format. Here is Java example for converting String Date... convert date to yyyy-mm-dd format */ public class DateToStringConversion
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 current date into yyyy-mm-dd in Java
How to format current date into yyyy-mm-dd in Java  Hi, I have requirement to format the date into yyyy-MM-dd format for inserting it into MySQL...-dd"); formats the date into yyyy-MM-dd format. the MM is used for getting
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
the 'emp_dob ' records in 'yyyy-mm-dd' format. select emp_dob from employee: The select query return the emp_dob  records in "yyyy-mm-dd" format...; 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
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 - 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
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
Struts 2 Date Format Examples
; <tr> <td>Date in (MM/dd/yyyy hh:mm AM/PM) Format:</td> <td> <b><s:date name="todayDate" format="MM/dd/yyyy...;tr> <td>Date in (dd-MMM-yyyy hh:mm AM/PM) Format:</td>
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
struts2.2.1 date Format example
;Date Format(EEEE yyyy-MM-dd):</b><br/><br/> <s:date name..._TO_REPLACE_25 <hr> <b>Date Format (EEEE MM/dd/yyyy hh:mm AM/PM):<...;b>Date Format (EEEE dd-MMM-yyyy hh:mm AM/PM) :</b><br/><br
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
Simple date formatter example
the date object into the "yyyy-MM-dd HH:mm:ss" format. formatter = new SimpleDateFormat("yyyy-MM-dd"); formattedDate = formatter.format(todaysDate);ADS... SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss
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
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
NSDateformatter format Date
NSDateformatter format Date  Hi, What is the correct way of writing NSDateFormatter in string format. Thanks.   For current Date in NSDate... that represent other data types. For example to show the date in string format we'll
Mysql Date and Time
a date time format Query in different ways. now ( )  :The below Query return you the current date in yyyy-mm-dd and time in hh:mm:ss.ADS_TO_REPLACE_1 Query... Mysql Date and Time      
date format in javascript
date format in javascript  display date format as dd/mm/yyyy and day... help me. thank u var date=/^\d{2}\/\d{2}\/\d{4}$/ if( { alert("please enter date format as dd/mm/yyyy
Hibernate Date Format
This section contains description of Hibernate Date Format
date format - Java Beginners
date format  how to 45day in dd-mmm-yyyy date format.  Hi...-yyyy", Locale.US); Date d = sdf.parse(timestamp); Calendar cal...()); SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); String
JDBC : Current Date
, CURRENT_DATE() functions  return the current date in format 'YYYY-MM-DD... the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' SYSDATE()  : It returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS
Date not getting in proper format
Date not getting in proper format  import java.util.*; class Date { public static void main(String[]args) { Date d = new Date(100000000000L); System.out.print("1st date"+d.toString()); } } out put:- 1st date@3e25
date format updated
date format updated  package LvFrm; import java.awt.Color; import... panel1,panel2,panel3,panel4; Font f1; JComboBox i1,j1,k1; JButton b1,b2; //for date...); panel2.setBorder(b2); frm.add(panel2); /*for date entry & adding
Mysql Date Format
Mysql Date Format       Mysql Date Format explains you the way of formatting Date... Date Format'. To understand this example we show you the following Syntax used
Date Format required to change in java
Date Format required to change in java  can we change the format of date like sql as per our requirements???If yes then please give the detail solution
Change Date Format - Development process
Change Date Format   Hi, i hav used following line get date field from database . But my output is 2009/26/5. How to change the format
  date_parse_from_format date_parse_from_format function returns... date_parse_from_format ( string $format , string $date ) Parameters of Date Parse Function PHP format - Format accepted by date() with some extras. date
Simple Date Format Example
SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z"); s = formatter.format(date... formatter = new SimpleDateFormat("MM/dd/yy"); s = formatter.format(date...Following is a simple date format example made using Format class. We have
Format date/time using <fmt:formatDate> tag of jstl
by user in what pattern user want to format. For example: dd-mm...%">Attribute : pattern="yyyy-MM-dd hh:mm:ss"</td> <td width="49%"><fmt:formatDate pattern="yyyy-MM-dd hh:mm
ask java - Date Calendar
(); SimpleDateFormat sdf; //sdf = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss aa"); sdf = new SimpleDateFormat("yyyy/MM/dd"); System.out.println("date... SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy/MM/dd"); //parse
Date prorblem
) in java code, then i have to convert it into yyyy-mm-dd hh-mm-ss. then i have...) SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); DATEADDED1...Date prorblem  HI all, i have date comming from one text file