You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by fa...@apache.org on 2024/10/26 23:03:40 UTC
(drill) branch pjfanning-patch-2 created (now 99bbde8c7f)
This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a change to branch pjfanning-patch-2
in repository https://gitbox.apache.org/repos/asf/drill.git
at 99bbde8c7f Fix DateFormat in DateGen.java
This branch includes the following new commits:
new 99bbde8c7f Fix DateFormat in DateGen.java
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(drill) 01/01: Fix DateFormat in DateGen.java
Posted by fa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch pjfanning-patch-2
in repository https://gitbox.apache.org/repos/asf/drill.git
commit 99bbde8c7f675305b7fccfe4779fe1f9153c7eff
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sun Oct 27 00:03:32 2024 +0100
Fix DateFormat in DateGen.java
---
.../main/java/org/apache/drill/exec/store/mock/DateGen.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java
index cc5b63aad6..47c3990300 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java
@@ -44,13 +44,16 @@ public class DateGen extends AbstractFieldGen {
public DateGen() {
// Start a year ago.
baseTime = System.currentTimeMillis() - ONE_YEAR;
- fmt = new SimpleDateFormat("yyyy-mm-DD");
+ fmt = new SimpleDateFormat("yyyy-MM-dd");
}
@Override
public void setValue() {
- long randTime = baseTime + baseTime + rand.nextInt(365) * ONE_DAY;
- String str = fmt.format(new Date(randTime));
- colWriter.setString(str);
+ final long randTime = baseTime + baseTime + rand.nextInt(365) * ONE_DAY;
+ final Date date = new Date(randTime);
+ // SimpleDateFormat is not thread safe
+ synchronized(fmt) {
+ colWriter.setString(fmt.format(date));
+ }
}
}