bug4210 Adjusted internal format of accuracy enumeration

This commit is contained in:
Benjamin Barth committed 2017-11-20 13:18:07 +01:00
1 parent ebb5656108
commit 1187cac58e
5 files changed
+13 -11

No files matched your search

@@ -46,8 +46,8 @@ public class DateAndTimeInput extends Composite implements DateTimeInput {
add(this.dateInput = new DateInput());
add(this.timeInput = new TimeInput(accuracy));
this.dateFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
this.timeFormat = DateTimeFormat.getFormat(accuracy.getTimeFormat());
this.datetimeFormat = DateTimeFormat.getFormat(accuracy.getDatetimeFormat());
this.timeFormat = accuracy.getTimeFormat();
this.datetimeFormat = accuracy.getDatetimeFormat();
}
@Override
@@ -3,31 +3,33 @@ package com.sap.sailing.gwt.common.client.datetime;
import java.util.Date;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.IsWidget;
public interface DateTimeInput extends IsWidget, HasValue<Date> {
enum Accuracy {
public enum Accuracy {
MINUTES(60, "yyyy-MM-dd'T'HH:mm", "HH:mm"), SECONDS(1, "yyyy-MM-dd'T'HH:mm:ss", "HH:mm:ss");
private final String step, datetimeFormat, timeFormat;
private final String step;
private final DateTimeFormat datetimeFormat, timeFormat;
private Accuracy(int step, String datetimeFormat, String timeFormat) {
this.step = String.valueOf(step);
this.datetimeFormat = datetimeFormat;
this.timeFormat = timeFormat;
this.datetimeFormat = DateTimeFormat.getFormat(datetimeFormat);
this.timeFormat = DateTimeFormat.getFormat(timeFormat);
}
public String getStep() {
return step;
}
public String getDatetimeFormat() {
public DateTimeFormat getDatetimeFormat() {
return datetimeFormat;
}
public String getTimeFormat() {
public DateTimeFormat getTimeFormat() {
return timeFormat;
}
}
@@ -21,7 +21,7 @@ class NativeDatetimeLocalInput extends Widget implements DateTimeInput {
this.input = Document.get().createElement(InputElement.TAG).cast();
this.input.setAttribute(ATTR_TYPE, DateTimeInputType.DATETIME_LOCAL.getType());
this.input.setAttribute(ATTR_STEP, accuracy.getStep());
this.format = DateTimeFormat.getFormat(accuracy.getDatetimeFormat());
this.format = accuracy.getDatetimeFormat();
setElement(input);
}
@@ -21,7 +21,7 @@ class NativeTimeInput extends Widget implements DateTimeInput {
this.input = Document.get().createElement(InputElement.TAG).cast();
this.input.setAttribute(ATTR_TYPE, DateTimeInputType.TIME.getType());
this.input.setAttribute(ATTR_STEP, accuracy.getStep());
this.format = DateTimeFormat.getFormat(accuracy.getTimeFormat());
this.format = accuracy.getTimeFormat();
setElement(input);
}
@@ -58,7 +58,7 @@ public class TimeInput extends Composite implements DateTimeInput {
private final DateTimeFormat timeFormat;
private TimeConverter(Accuracy accuracy) {
this.timeFormat = DateTimeFormat.getFormat(accuracy.getTimeFormat());
this.timeFormat = accuracy.getTimeFormat();
}
@Override