Use ZonedDateTime instead of LocalDateTime. Fixes #15
This commit is contained in:
parent
1afb27745d
commit
f2a495a7be
6 changed files with 19 additions and 21 deletions
|
@ -32,7 +32,7 @@ import javax.persistence.FetchType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Transient;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* @author Lukas
|
||||
|
@ -47,7 +47,7 @@ public class Report {
|
|||
private Stacktrace stacktrace;
|
||||
@Type(type = "text") private String content;
|
||||
@Transient private JSONObject jsonObject;
|
||||
private LocalDateTime date;
|
||||
private ZonedDateTime date;
|
||||
private String userEmail;
|
||||
@Type(type = "text") private String userComment;
|
||||
private String androidVersion;
|
||||
|
@ -86,7 +86,7 @@ public class Report {
|
|||
}
|
||||
|
||||
@NonNull
|
||||
public LocalDateTime getDate() {
|
||||
public ZonedDateTime getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.faendir.acra.model.view;
|
|||
import com.faendir.acra.model.Bug;
|
||||
import com.querydsl.core.annotations.QueryProjection;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* @author lukas
|
||||
|
@ -27,13 +27,13 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
public class VBug {
|
||||
private final Bug bug;
|
||||
private final LocalDateTime lastReport;
|
||||
private final ZonedDateTime lastReport;
|
||||
private final long reportCount;
|
||||
private final int highestVersionCode;
|
||||
private final long userCount;
|
||||
|
||||
@QueryProjection
|
||||
public VBug(Bug bug, LocalDateTime lastReport, long reportCount, int highestVersionCode, long userCount) {
|
||||
public VBug(Bug bug, ZonedDateTime lastReport, long reportCount, int highestVersionCode, long userCount) {
|
||||
this.bug = bug;
|
||||
this.lastReport = lastReport;
|
||||
this.reportCount = reportCount;
|
||||
|
@ -49,7 +49,7 @@ public class VBug {
|
|||
return reportCount;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastReport() {
|
||||
public ZonedDateTime getLastReport() {
|
||||
return lastReport;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -69,7 +68,6 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -288,7 +286,7 @@ public class DataService implements Serializable {
|
|||
|
||||
@Transactional
|
||||
public void deleteReportsOlderThanDays(@NonNull App app, @NonNull int days) {
|
||||
new JPADeleteClause(entityManager, report).where(report.stacktrace.bug.app.eq(app).and(report.date.before(LocalDateTime.now().minus(days, ChronoUnit.DAYS))));
|
||||
new JPADeleteClause(entityManager, report).where(report.stacktrace.bug.app.eq(app).and(report.date.before(ZonedDateTime.now().minus(days, ChronoUnit.DAYS))));
|
||||
entityManager.flush();
|
||||
deleteOrphanBugs();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.vaadin.ui.Component;
|
|||
import com.vaadin.ui.ComponentContainer;
|
||||
import org.vaadin.risto.stepper.IntStepper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.function.Function;
|
||||
|
@ -91,13 +91,13 @@ class Property<F, C extends Component & HasValue<F>, T> {
|
|||
return new Property<>(filterText, comboBox, stringExpression::eq, new PieChart(chartTitle), dataService, stringExpression);
|
||||
}
|
||||
|
||||
Property<?, ?, ?> createAgeProperty(String filterText, String chartTitle, DateTimePath<LocalDateTime> dateTimeExpression) {
|
||||
Property<?, ?, ?> createAgeProperty(String filterText, String chartTitle, DateTimePath<ZonedDateTime> dateTimeExpression) {
|
||||
IntStepper stepper = new IntStepper();
|
||||
stepper.setValue(30);
|
||||
stepper.setMinValue(1);
|
||||
return new Property<>(filterText,
|
||||
stepper,
|
||||
days -> dateTimeExpression.after(LocalDateTime.now().minus(days, ChronoUnit.DAYS)),
|
||||
days -> dateTimeExpression.after(ZonedDateTime.now().minus(days, ChronoUnit.DAYS)),
|
||||
new TimeChart(chartTitle),
|
||||
dataService,
|
||||
SQLExpressions.date(Date.class, dateTimeExpression));
|
||||
|
|
|
@ -22,7 +22,7 @@ import elemental.json.JsonValue;
|
|||
import org.springframework.lang.Nullable;
|
||||
import org.xbib.time.pretty.PrettyTime;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,8 @@ import java.util.Locale;
|
|||
public class TimeSpanRenderer extends TextRenderer {
|
||||
@Override
|
||||
public JsonValue encode(@Nullable Object value) {
|
||||
if (value instanceof LocalDateTime) {
|
||||
return Json.create(new PrettyTime(Locale.US).formatUnrounded((LocalDateTime) value));
|
||||
if (value instanceof ZonedDateTime) {
|
||||
return Json.create(new PrettyTime(Locale.US).formatUnrounded(((ZonedDateTime) value).toLocalDateTime()));
|
||||
}
|
||||
return super.encode(value);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.io.PrintWriter;
|
|||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,11 +48,11 @@ public final class Utils {
|
|||
private static final Log log = LogFactory.getLog(Utils.class);
|
||||
|
||||
@NonNull
|
||||
public static LocalDateTime getDateFromString(@NonNull String s) {
|
||||
public static ZonedDateTime getDateFromString(@NonNull String s) {
|
||||
try {
|
||||
return LocalDateTime.parse(s, formatter);
|
||||
return ZonedDateTime.parse(s, formatter);
|
||||
} catch (DateTimeParseException e) {
|
||||
return LocalDateTime.now();
|
||||
return ZonedDateTime.now();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue