Mercurial > stress-tester
changeset 1159:2f509607b05d
DateTimeGenerator improvements
author | Devel 2 |
---|---|
date | Mon, 15 Jun 2020 13:30:16 +0200 |
parents | 539e52cb5d8c |
children | 2d5c66bd2224 |
files | stress-tester/src/main/java/com/passus/st/generator/DateTimeGenerator.java |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/generator/DateTimeGenerator.java Mon Jun 15 12:47:22 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/generator/DateTimeGenerator.java Mon Jun 15 13:30:16 2020 +0200 @@ -116,12 +116,17 @@ @Override public Object generate() { long time = startTime + (long) (Math.random() * (endTime - startTime)); - DateTime dateTime = time > 0 ? new DateTime(time) : new DateTime(); - if (returnType == ReturnType.DATETIME) { - return dateTime; + if (time < 0) { + return null; } - return formatter.print(dateTime); + if (returnType == ReturnType.DATETIME) { + return new DateTime(time); + } + + synchronized (this) { + return formatter.print(time); + } } public static final class DateTimeNodeDefCreator implements NodeDefinitionCreator {