aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java')
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java b/server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java
index 9314f5d9b9..a2d4b0f3aa 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractLocalDateField.java
@@ -103,8 +103,8 @@ public abstract class AbstractLocalDateField
@Override
protected RangeValidator<LocalDate> getRangeValidator() {
return new DateRangeValidator(getDateOutOfRangeMessage(),
- getDate(getRangeStart(), getResolution()),
- getDate(getRangeEnd(), getResolution()));
+ adjustToResolution(getRangeStart(), getResolution()),
+ adjustToResolution(getRangeEnd(), getResolution()));
}
@Override
@@ -134,7 +134,9 @@ public abstract class AbstractLocalDateField
return Date.from(date.atStartOfDay(ZoneOffset.UTC).toInstant());
}
- private LocalDate getDate(LocalDate date, DateResolution forResolution) {
+ @Override
+ protected LocalDate adjustToResolution(LocalDate date,
+ DateResolution forResolution) {
if (date == null) {
return null;
}
@@ -171,19 +173,21 @@ public abstract class AbstractLocalDateField
protected Result<LocalDate> handleUnparsableDateString(String dateString) {
// Handle possible week number, which cannot be parsed client side due
// limitations in GWT
- if (this.getDateFormat() != null && this.getDateFormat().contains("w")) {
+ if (getDateFormat() != null && getDateFormat().contains("w")) {
Date parsedDate;
- SimpleDateFormat df = new SimpleDateFormat(this.getDateFormat(),this.getLocale());
+ SimpleDateFormat df = new SimpleDateFormat(getDateFormat(),
+ getLocale());
try {
parsedDate = df.parse(dateString);
} catch (ParseException e) {
return super.handleUnparsableDateString(dateString);
}
- ZoneId zi = this.getZoneId();
- if (zi == null) {
+ ZoneId zi = getZoneId();
+ if (zi == null) {
zi = ZoneId.systemDefault();
}
- LocalDate date = Instant.ofEpochMilli(parsedDate.getTime()).atZone(zi).toLocalDate();
+ LocalDate date = Instant.ofEpochMilli(parsedDate.getTime())
+ .atZone(zi).toLocalDate();
return Result.ok(date);
} else {
return super.handleUnparsableDateString(dateString);