Convert String yyyy-mm-dd to month name

I have a string file FECHA EMISION="2018-03-02". To show like "Marzo" I have to convert

$F{FECHA EMISION}.substring(5,7) 

in integer. But I don´t know how convert the result 02 to the month related

 

maycarb's picture
71
Joined: Jan 24 2019 - 4:02pm
Last seen: 4 years 1 month ago

3 Answers:

Hi,

You can do this using a date format. Possible date formats can be found here (for example): https://community.jaspersoft.com/wiki/date-and-time-patterns A pattern can be added to a textfield in the properties of a textield (in the properties find pattern).

Another reference on the use of date patterns can be found here: http://jasperguide.blogspot.com/2014/03/date-and-time-pattern.html

Hope this helps.

Kind regards,

Maarten

 

mtn's picture
mtn
240
Joined: Aug 22 2017 - 4:41am
Last seen: 1 year 3 months ago

Try the following.

(new SimpleDateFormat("MMMMM", (new Locale("es")))).format((new SimpleDateFormat("yyyy-MM-dd")).parse("2018-03-02"))

hozawa's picture
170167
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 9 months ago

Thanks.

I try this and works correctly

UPPER(DATEFORMAT(new SimpleDateFormat("yyyy-MM-dd").parse($F{FECHA EMISION}), "MMMMM"))

It shows me MARZO

 

maycarb's picture
71
Joined: Jan 24 2019 - 4:02pm
Last seen: 4 years 1 month ago
Feedback