Skip to content

Commit 0e8d435

Browse files
committed
Java: Add a test for java/suspicious-date-format.
1 parent 708890a commit 0e8d435

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import java.text.SimpleDateFormat;
2+
import java.util.Date;
3+
4+
public class A {
5+
public static void main(String[] args) {
6+
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); // OK
7+
System.out.println(new SimpleDateFormat("YYYY-ww").format(new Date())); // OK
8+
System.out.println(new SimpleDateFormat("YYYY-MM-dd").format(new Date())); // BAD
9+
}
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| A.java:8:22:8:55 | new SimpleDateFormat(...) | Date formatter is passed a suspicious pattern "YYYY-MM-dd". |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Likely Bugs/Likely Typos/SuspiciousDateFormat.ql

0 commit comments

Comments
 (0)