How i can to convert a Date that is null to String

0

 

I want to put a default text to a field type date that comes null

rene.marquez's picture
Joined: Jun 26 2019 - 9:38am
Last seen: 2 weeks 3 days ago

thanks,!! I have solved my problem   ... lml ...lml

rene.marquez - 3 weeks 1 hour ago

1 Answer:

1

Just use a simple IfThenElse Expression for your date field (e.g. here without text pattern for a java.util.Date Field, but  instead with a SimpleDateFormat for a plain StringField):

$F{YourDateField} == null ? "no date found": new SimpleDateFormat("dd.MM.yyyy").format($F{YourDateField})

If you have multiple date fields and you just want to define the static text once, you also could use an own parameter (without prompting) with a default expression for your default static text:

$F{YourDateField} == null ? $P{YourDefaultText4NullDates}: new SimpleDateFormat("dd.MM.yyyy").format($F{YourDateField})

Another way could also be a static scriptlet method within a small java proggi that handles your logic on a central point:

YourScriptletClass.getDateOrText($F{YourDateField})

so like always: Many ways leading to Rome :-)

hth + regards

C-Box

C-Box's picture
1622
Joined: Jul 19 2006 - 5:58pm
Last seen: 2 days 9 hours ago
Feedback
randomness