0

I was reading about Date vs TimeStamp vs calendar? because I´m sending toprint a report this parameters:

startDate = 2018-01-01T00:00:00+00:00

endDate = 2018-01-01T00:00:00+00:00

And at the begining of my report y print this variables formated as DD-MM-yyyy.

           <textField pattern="dd/MM/yyyy">
                <reportElement x="0" y="0" width="102" height="30" uuid="a0865739-1233-463e-8f93-77f75024e9dc"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{startDay}]]></textFieldExpression>
            </textField>
            <textField pattern="dd/MM/yyyy">
                <reportElement x="204" y="0" width="102" height="30" uuid="ff76b864-ef55-4fcc-82d5-323c6291b7ed"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{endDay}]]></textFieldExpression>
            </textField>

Execute in GMT+0

If I declare the parameter as Java.util.Date I get 31-12-2017 23:00:00

But If I declarea the parameter as java.sql.Timestamp I get 01-01-2018 00:00:00

Willas
  • 63
  • 1
  • 10
  • Almost certainly a time zone issue. Asking naively, can you use `LocalDate` from `java.time` with Jasper Reports? A `LocalDate` is a date without time of day, so I gather it would eliminate your problem. – Ole V.V. Jan 18 '18 at 09:17
  • @Willas What is your question? Why JRServer was added as tag? – Alex K Jan 18 '18 at 09:29
  • @AlexK At login-request in JRServer I have `userTimeZone=Atalantic/Canary`. And I think the time zone has something to do with how that data is shown. Because the server is supposed to be working in GMT+0 and the Date is in GMT+0 too. – Willas Jan 18 '18 at 09:50
  • 1
    In jasperserver timezone applied to java.sql.Timestamp and java.sql.Time. Java.util.Date is timezone independent in jasperserver. Java.util.Date is used only to date filed like yyyy-MM-dd, and when you use is as timestamp you would get issues. – V. Spachynskyi Jan 31 '18 at 14:36

0 Answers0