i have this code in my JasperReport like that new SimpleDateFormat("dd/MM/yyyy").format(new Date()) - 24 * 3600 * 1000 but it's not working, what i'm trying is substract one day from today. But it's displaying the day of today like that
<textFieldExpression><![CDATA["Test: " + new SimpleDateFormat("dd/MM/yyyy").format(new Date()) - 24 * 3600 * 1000]]></textFieldExpression>
As far as I can see, this code obviously ignores the
- 24 * 3600 * 1000because the expressionnew SimpleDateFormat("dd/MM/yyyy").format(new Date())determines the value before you try to subtract one day ignoring the arithmetic that follows. It only considers thenew Date(), which is today.You should include the calculation before formatting, e.g.
If you are on Java 8 or higher, I would use
java.time, maybe like this: