0

I'm new in Java, i use Java with OFBiz, i have a search form that has date-time input field for searching, when no date-time is selected and form submitted, in Java follow error occur:

Timestamp format must be YYYY-MM-DD HH:MM:SS[.FFFFFFFFF]

So how i can avoid from this? bellow is my code block:

String sDate = request.getParameter('sdate_field');
if(sDate != null)
{
     condition = new EntityXpr("crt_date",Operator.LESS_THAN_EQUAL_TO,Timestamp.valueOf(sDate));
}
jones
  • 1,423
  • 3
  • 35
  • 76

1 Answers1

1

In OFBiz you can do

if (UtilValidate.isNotEmpty(userLogin)) {
    condition = new EntityXpr("crt_date",Operator.LESS_THAN_EQUAL_TO,Timestamp.valueOf(sDate));
}

See org.ofbiz.base.util.* for more convenience methods.

Michael Brohl
  • 782
  • 5
  • 21