Formatting dates in Java

1

Good afternoon, I have a date attribute of an object that persists as a string, needing it in ddMMyyyy format at a certain location, and also compare to an earlier date. But at another time I need this same attribute to generate a report in the long form "dd of year month". The fact is that I already tried to do this in the jasper when I call the attribute but I have not had success yet. the closest I came up was to use substrings to separate the date but I can not find a way to make the month that is in numeric format be displayed in detail in the report. Someone has a suggestion.

    
asked by anonymous 04.01.2016 / 17:12

1 answer

3

You can use date formatters from the Java API itself, such as SimpleDateFormat

Ex:

new SimpleDateFormat("dd/MM/yyyy").format($P{nomeParametro})

While generating the report by Jasper Reports , be sure to change to Language Java .

After formatting, you can convert from Date to String and vice versa, if you need to perform date manipulation.

link

    
04.01.2016 / 17:27