Preset the TimeZone of DateTimeField

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Preset the TimeZone of DateTimeField

Ulrich
I want the enduser to set the datetimefield as UTC-time. I want to make sure ît is handled as UTC at program side - not to rely on the server settings.
When I display the entered DateTimeField with the "getModelObject().toString()"  it displays those values indicating that they represent the server timezone. That means UTC is different.
The only chance I see to handle the number as UTC themselves is that I need to retrieve the Date().getTimeZoneOffset() and calculate the Date myself.
Is the DateTimeField.changeTimeZone()-method of an help here? I don't see what it is meant for right now.

My code looks like this:
final DateTimeField dateField = new DateTimeField("edate", new PropertyModel<Date>(this, "selectedDate")) {
			@Override
			protected boolean use12HourFormat() {
				return false;
			}
		};
		add(dateField);
		add(dateEnd);
...

public Date getSelectedDate() {
		return new Date();
	}