jBPM Console NG - Generic Client 6.1.0.Final

org.jbpm.console.ng.gc.client.util
Class UTCDateBox

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.jbpm.console.ng.gc.client.util.UTCDateBox
All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<Long>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.TakesValue<Long>, com.google.gwt.user.client.ui.HasEnabled, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.ui.HasValue<Long>, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget

public class UTCDateBox
extends com.google.gwt.user.client.ui.Composite
implements com.google.gwt.user.client.ui.HasValue<Long>, com.google.gwt.event.logical.shared.HasValueChangeHandlers<Long>, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.ui.HasEnabled

A wrapper around a DateBox that implements HasValue where the value is the number of milliseconds since January 1, 1970, 00:00:00 GMT at midnight on the day, month, and year selected. This avoids time zone conversion issues encountered using the DateBox.

Note: In keeping with the behavior of the GWT DateBox, null is used to represent no value. This means that you should check for null when calling getValue(), just as you would for DateBox. With auto-boxing Long/long, this may seem strange but is consistent.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
static long DAY_IN_MS
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
UTCDateBox()
          Creates a new UTCDateBox with the medium date format for the current locale.
UTCDateBox(com.google.gwt.user.datepicker.client.DatePicker picker, long date, com.google.gwt.user.datepicker.client.DateBox.Format format)
          Deprecated. Use UTCDateBox(DateTimeFormat) instead. DatePicker and DateBox.Format are now ignored.
UTCDateBox(com.google.gwt.i18n.client.DateTimeFormat format)
          Creates a new UTCDateBox with the specified date format.
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Long> handler)
           
static Long date2utc(Date date)
          Converts a gwt Date in the timezone of the current browser to a time in UTC.
 com.google.gwt.user.datepicker.client.DateBox getDateBox()
           
 String getText()
           
 Long getValue()
          Returns the date value specified by the DateBox measured in number of milliseconds since January 1, 1970, 00:00:00 GMT.
static Long getValueForToday()
           
 boolean isEnabled()
           
 void setEnabled(boolean enabled)
           
 void setTabIndex(int tabIndex)
          Sets the tabindex for this control.
 void setText(String text)
           
 void setValue(Long value)
          Sets the value in the DateBox.
 void setValue(Long value, boolean fireEvents)
          Sets the value in the DateBox.
 void setVisibleLength(int length)
          Sets the visible length of the text input for this date box.
static long timezoneOffsetMillis(Date date)
          Returns the timezone offset for the specified Date.
static long trimTimeToMidnight(long time)
           
static Date utc2date(Long time)
          Converts a time in UTC to a gwt Date object which is in the timezone of the current browser.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Field Detail

DAY_IN_MS

public static final long DAY_IN_MS
See Also:
Constant Field Values
Constructor Detail

UTCDateBox

public UTCDateBox()
Creates a new UTCDateBox with the medium date format for the current locale.


UTCDateBox

public UTCDateBox(com.google.gwt.i18n.client.DateTimeFormat format)
Creates a new UTCDateBox with the specified date format.


UTCDateBox

@Deprecated
public UTCDateBox(com.google.gwt.user.datepicker.client.DatePicker picker,
                             long date,
                             com.google.gwt.user.datepicker.client.DateBox.Format format)
Deprecated. Use UTCDateBox(DateTimeFormat) instead. DatePicker and DateBox.Format are now ignored.

Creates a new UTCDateBox

Method Detail

getText

public String getText()
Specified by:
getText in interface com.google.gwt.user.client.ui.HasText

setText

public void setText(String text)
Specified by:
setText in interface com.google.gwt.user.client.ui.HasText

getValue

public Long getValue()
Returns the date value specified by the DateBox measured in number of milliseconds since January 1, 1970, 00:00:00 GMT. This time will always correspond to midnight in GMT on the date selected.

Specified by:
getValue in interface com.google.gwt.user.client.TakesValue<Long>
Specified by:
getValue in interface com.google.gwt.user.client.ui.HasValue<Long>
Returns:
The time selected or null if no value is specified by the DateBox.

setValue

public void setValue(Long value)
Sets the value in the DateBox.

Specified by:
setValue in interface com.google.gwt.user.client.TakesValue<Long>
Specified by:
setValue in interface com.google.gwt.user.client.ui.HasValue<Long>
Parameters:
value - A time measured in the number of milliseconds since January 1, 1970, 00:00:00 GMT. This time should be at midnight in GMT for the Date selected.

If value is null or represents a negative number, the DateBox will have no value.


setValue

public void setValue(Long value,
                     boolean fireEvents)
Sets the value in the DateBox.

Specified by:
setValue in interface com.google.gwt.user.client.ui.HasValue<Long>
Parameters:
value - A time measured in the number of milliseconds since January 1, 1970, 00:00:00 GMT. This time should be at midnight in GMT for the Date selected.

If value is null or represents a negative number, the DateBox will have no value.


addValueChangeHandler

public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<Long> handler)
Specified by:
addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<Long>

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface com.google.gwt.user.client.ui.HasEnabled

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface com.google.gwt.user.client.ui.HasEnabled

setVisibleLength

public void setVisibleLength(int length)
Sets the visible length of the text input for this date box. This will be ignored for HTML5 inputs.


setTabIndex

public void setTabIndex(int tabIndex)
Sets the tabindex for this control.


getDateBox

public com.google.gwt.user.datepicker.client.DateBox getDateBox()

trimTimeToMidnight

public static final long trimTimeToMidnight(long time)

utc2date

public static final Date utc2date(Long time)
Converts a time in UTC to a gwt Date object which is in the timezone of the current browser.

Returns:
The Date corresponding to the time, adjusted for the timezone of the current browser. null if the specified time is null or represents a negative number.

date2utc

public static final Long date2utc(Date date)
Converts a gwt Date in the timezone of the current browser to a time in UTC.

Returns:
A Long corresponding to the number of milliseconds since January 1, 1970, 00:00:00 GMT or null if the specified Date is null.

getValueForToday

public static final Long getValueForToday()

timezoneOffsetMillis

public static final long timezoneOffsetMillis(Date date)
Returns the timezone offset for the specified Date.


jBPM Console NG - Generic Client 6.1.0.Final

Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.