Jasper Reporting

Date and time Pattern in Jasper Reporting

The following are the different type of Date and Time pattern in Jasper Reporting.

Note: Before applying Date and Time pattern you filed values should be in Datetime format or your need to convert into datetime if you filed type is String.

Use the following expression to convert String to Date

javax.xml.bind.DatatypeConverter.parseDateTime($F{Date}).getTime()

If the filed is String, using the below code to convert to String to Date format

<textField pattern="yyyy-MM-dd" isBlankWhenNull="true">
					<reportElement style="ParamValue_TXT" x="419" y="35" width="135" height="15" uuid="e32b1b62-b51d-4a3d-9a8b-56e82d49834f">
						<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
						<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
						<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
					</reportElement>
					<textElement textAlignment="Left" verticalAlignment="Middle"/>
					<textFieldExpression><![CDATA[javax.xml.bind.DatatypeConverter.parseDateTime($F{Date}).getTime()]]></textFieldExpression>
				</textField>

Now you can apply date format by following the below steps.

  1. Go to Text Filed Properties
  2. Click the Pattern Expression
  3. Select the “Date”
  4. and Select the data format which one you want.

Thank You.!!

Leave a Reply

Prabhakaran Jayaraman