Jump to content
We've recently updated our Privacy Statement, available here ×

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


rene.marquez
Go to solution Solved by C-Box,

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

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})[/code]

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})[/code]

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})[/code]

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

hth + regards

C-Box

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...