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

Ads
 

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="com.xxxxx.xxx"   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" />

                   </list>
           </property>
           <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"

when

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");

end

View Answers

Ads









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
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
Advertisements
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
' 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
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
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
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
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. Query for displaying... Mysql Date and Time      
JDBC : Current Date
() functions  return the current date in format 'YYYY-MM-DD'. CURRENT... 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' . Example
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
Hibernate Date Format
This section contains description of Hibernate Date 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
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(document.userform.joindate.value.search(date)==-1) { alert("please enter date format as dd/mm/yyyy
Mysql Date Format
Mysql Date Format       Mysql Date Format explains you the way of formatting Date. Understand with Example The Tutorial elaborate an example from 'Mysql Date Format
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 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
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
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
Format date/time using <fmt:formatDate> tag of jstl
to format. For example: dd-mm-yyyy timeZone... pattern="yyyy-MM-dd hh:mm:ss" value="${date}" /></td>...="yyyy-MM-dd" value="${date}" /> </td> </tr>
Simple Date Format Example
, dd MMM yyyy HH:mm:ss Z"); s = formatter.format(date); System.out.println(s); formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy HH:mm:ss zzzz... SimpleDateFormat("MM/dd/yy"); s = formatter.format(date

Ads