Skip to content

Commit

Permalink
Fix DateFormat in DateGen.java
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Oct 26, 2024
1 parent 138563a commit 99bbde8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

0 comments on commit 99bbde8

Please sign in to comment.