Skip to content

Commit d5358d6

Browse files
authored
Fix DateFormat in DateGen.java (#2959)
1 parent 0e79439 commit d5358d6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • exec/java-exec/src/main/java/org/apache/drill/exec/store/mock

exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ public class DateGen extends AbstractFieldGen {
4444
public DateGen() {
4545
// Start a year ago.
4646
baseTime = System.currentTimeMillis() - ONE_YEAR;
47-
fmt = new SimpleDateFormat("yyyy-mm-DD");
47+
fmt = new SimpleDateFormat("yyyy-MM-dd");
4848
}
4949

5050
@Override
5151
public void setValue() {
52-
long randTime = baseTime + baseTime + rand.nextInt(365) * ONE_DAY;
53-
String str = fmt.format(new Date(randTime));
54-
colWriter.setString(str);
52+
final long randTime = baseTime + rand.nextInt(365) * ONE_DAY;
53+
final Date date = new Date(randTime);
54+
// SimpleDateFormat is not thread safe
55+
synchronized(fmt) {
56+
colWriter.setString(fmt.format(date));
57+
}
5558
}
5659
}

0 commit comments

Comments
 (0)