
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to retrieve Month part of a Date returns previous Month instead. Bug?
The TalendDate.getPartOfDate("MONTH", " ") method returns the previous month instead of the current month. Is this a known bug? I need to identify the current and previous months of a date, but this method does not work as expected.
In this example, the returned month should October (10), but TalendDate.getPartOfDate("MONTH"," ") returns September (9). See attached file
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have encountered date libraries before that return the month using a zero-based index, so 0 is January and 11 is December. This may not be a bug. Existing code that relies on this behaviour would be broken if this were changed.
The java.util.Calendar class specifically has this behaviour:
https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html
MONTH
public static final int MONTH
See Also: JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER, UNDECIMBER, Constant Field Values

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @elkhounds
Good catch and I also got the same result when I tried to run it in Talend 7.2
I have reported the Bug to the Product Team through JIRA. Please use the link below to track the progress of this ticket.
https://jira.talendforge.org/browse/TDI-43350
Appreciate again for identifying the issue 🙂
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have encountered date libraries before that return the month using a zero-based index, so 0 is January and 11 is December. This may not be a bug. Existing code that relies on this behaviour would be broken if this were changed.
The java.util.Calendar class specifically has this behaviour:
https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html
MONTH
public static final int MONTH
See Also: JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER, UNDECIMBER, Constant Field Values
