oscarfh Posted July 23, 2015 Share Posted July 23, 2015 I am new to Jasper Reprts.I am using Jaspersoft Studio to create reports and JasperReports Server to store/generate them.I created a blank report with a textField that gets populated by a parameter that is prompted to the user. This parameter should be a date that should be shown with date and time information.So I created a parameterParameter1Class: java.util.Date[/code]A Field:$P{Parameter1}[/code]Running in Jaspersoft Studio it works fine:I get the output "01/01/2015 10:00 PM" for instance.I updated it to the server and created a new inputcontrol with the same name as my parameter with the time date/time. When I open my report I am able to select date and time, but after applying the part time is ignored:I get "01/01/2015 12:00 AM", doesn't matter what I define on the time part (the date changes correctly). Question 1: Why is the time part of the date being ignored? How can I fix that?Question 2: When I make any changes on my report on Studio and upload it, the Input Control gets reset to "Date" only, I have to manually change it to Date/Time every time. How can I avoid reseting it? thanks my source (you will see that there is a second staticText and textField, these can be ignored because they are working correctly:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 --><!-- 2015-07-23T12:23:38 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ScheduleTest" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3998d57c-4d47-49c8-87ae-007544be8820"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <property name="ireport.jasperserver.url" value="http://localhost:8082/jasperserver/"/> <property name="ireport.jasperserver.user" value="jasperadmin"/> <property name="ireport.jasperserver.report.resource" value="/reports/ScheduleTest_files/main_jrxml"/> <property name="ireport.jasperserver.reportUnit" value="/reports/ScheduleTest"/> <parameter name="Parameter1" class="java.util.Date"> <defaultValueExpression><![CDATA[new java.util.Date(97, 5, 1)]]></defaultValueExpression> </parameter> <queryString> <![CDATA[]]> </queryString> <title> <band height="168" splitType="Stretch"> <textField pattern="M/d/yy h:mm a"> <reportElement x="250" y="20" width="100" height="30" uuid="6da64516-0352-4183-b213-730d874617c7"/> <textFieldExpression><![CDATA[$P{Parameter1}]]></textFieldExpression> </textField> <staticText> <reportElement x="133" y="20" width="100" height="30" uuid="2a45ecb5-5e33-4d27-bfca-7c35bef2e7d0"/> <text><![CDATA[Parameter]]></text> </staticText> <staticText> <reportElement x="133" y="80" width="100" height="30" uuid="e6340a3d-97bd-49bf-9053-9013c39c5d66"/> <text><![CDATA[Time:]]></text> </staticText> <textField pattern="HH:mm"> <reportElement x="250" y="80" width="140" height="30" uuid="0fe98c21-b56d-4bb8-b6bf-63e215e7c6ed"/> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> </band> </title></jasperReport>[/code] Link to comment Share on other sites More sharing options...
joel.carlson Posted August 31, 2015 Share Posted August 31, 2015 Have you tried setting the class to java.sql.TimeStamp Link to comment Share on other sites More sharing options...
oscarfh Posted September 2, 2015 Author Share Posted September 2, 2015 Yes, it works. Do you know if this bug is already known or if I should report it? Link to comment Share on other sites More sharing options...
joel.carlson Posted September 21, 2015 Share Posted September 21, 2015 I don't think it's a bug perse, more of just the way it works. A java.util.Date does just that, gets a Date only and if you wanted a date time then you just need to select the sql.TimeStamp which includes the date time. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now