Question
Conduent
IN
Last activity: 13 Oct 2021 12:41 EDT
Date Vaildation
Hello,
I have a Date property with edit validate configured to it to restrict user to select Current date or Future Date only. Earlier It was working fine from yesterday it is not accepting current date and throwing an error when we choose current date. I kindly request to solve my issue and below is the code I'm using in edit validate rule.
Thank you!!
if (theValue.trim().length() == 0) {
return false;
}
java.util.Date theDate = tools.getDateTimeUtils().parseDateTimeString(theValue);
java.util.Date presentDate= new java.util.Date();
theProperty.addMessage("Invalid date ");
return (theDate != null && (theDate.getDate()==presentDate.getDate() || theDate.after(new java.util.Date())));
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 13 Oct 2021 12:40 EDT
Maantic
IN
Attached.
Maantic
IN
Conduent
IN
Thanks for the reply but still it is throwing same error
Maantic
IN
Share the updated code.
Conduent
IN
Updated code
if (theValue.trim().length() == 0) {
return false;
}
java.util.Date theDate = tools.getDateTimeUtils().parseDateTimeString(theValue);
java.util.Date presentDate= new java.util.Date();
theProperty.addMessage("Invalid date ");
return (theDate != null && (theDate.getDate()==presentDate.getDate() || !theDate.before(new java.util.Date())));
Maantic
IN
you don't need to add the present day condition anymore. Just validate if date is not in past. This means date is either in present or future.
Conduent
IN
Updated Code
if (theValue.trim().length() == 0) {
return false;
}
java.util.Date theDate = tools.getDateTimeUtils().parseDateTimeString(theValue);
java.util.Date presentDate= new java.util.Date();
theProperty.addMessage("Invalid date ");
return (!theDate.before(new java.util.Date()));
If this is the code you are suggesting, this is also not working. I kindly request you to share me the right code.
Accepted Solution
Updated: 13 Oct 2021 12:40 EDT
Maantic
IN
Attached.
-
Akhil Reddy
Conduent
IN
Thank You very much Arvikmitra, there was some time zone miss match.