-
Notifications
You must be signed in to change notification settings - Fork 628
Closed
Description
Hello,
When validating a date format (rule FS_BAD_DATE_FORMAT_FLAG_COMBO), non-interpreted texts seems to be taken into account by the validator.
Example :
The following code :
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
public class TestDateFormat {
public String testDateFormat() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy à HH'h'mm", Locale.FRENCH);
return ZonedDateTime.now(ZoneId.systemDefault()).format(formatter);
}
}
generate the following error :
[ERROR] Medium: The 'd MMMM yyyy à HH'h'mm' date format string may lead to unexpected behavior used in testDateFormat() At TestDateFormat.java:[line XX] FS_BAD_DATE_FORMAT_FLAG_COMBO
Without the non-interpreted text 'h', no errors are reported.
Reproduced with spotbugs-maven-plugin version 4.9.3.0.
Best regards.
Metadata
Metadata
Assignees
Labels
No labels