public static Object getValue(ActionContext actionContext){ DateTime dt = (DateTime) actionContext.get("control"); GregorianCalendar c = new GregorianCalendar(); c.set(Calendar.HOUR_OF_DAY, dt.getHours()); c.set(Calendar.MINUTE, dt.getMinutes()); c.set(Calendar.SECOND, dt.getSeconds()); Date time = c.getTime(); SimpleDateFormat sf = new SimpleDateFormat((String) actionContext.get("pattern")); return sf.format(time); }
@Override protected Object doGetValue(Object source) { DateTime dateTime = (DateTime) source; Calendar cal = (Calendar) calendar.get(); cal.clear(); if ((dateTime.getStyle() & SWT.TIME) != 0) { cal.set(Calendar.HOUR_OF_DAY, dateTime.getHours()); cal.set(Calendar.MINUTE, dateTime.getMinutes()); cal.set(Calendar.SECOND, dateTime.getSeconds()); } else { cal.set(Calendar.YEAR, dateTime.getYear()); cal.set(Calendar.MONTH, dateTime.getMonth()); cal.set(Calendar.DAY_OF_MONTH, dateTime.getDay()); } return cal.getTime(); }
private void writeMinutes( final DateTime dateTime ) throws IOException { Integer newValue = new Integer( dateTime.getMinutes() ); if( WidgetLCAUtil.hasChanged( dateTime, PROP_MINUTES, newValue ) ) { JSWriter writer = JSWriter.getWriterFor( dateTime ); writer.set( PROP_MINUTES, newValue ); } }
/** * Sets the receiver's seconds. * <p> * Seconds is an integer between 0 and 59. * </p> * * @param seconds an integer between 0 and 59 * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setSeconds( int seconds ) { checkWidget(); if( checkTime( getHours(), getMinutes(), seconds ) ) { rightNow.set( Calendar.SECOND, seconds ); applyLimits(); } }
/** * Sets the receiver's hours. * <p> * Hours is an integer between 0 and 23. * </p> * * @param hours an integer between 0 and 23 * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setHours( int hours ) { checkWidget(); if( checkTime( hours, getMinutes(), getSeconds() ) ) { rightNow.set( Calendar.HOUR_OF_DAY, hours ); applyLimits(); } }
public DateTime getControlValueRaw() { if ( ( dateClock == null ) && ( timeClock == null ) ) { return null; // disabled, no value to use } DateTime now = null; if (useNowAsDate) now = new DateTime( DateTimeZone.getDefault() ); DateTime result = new DateTime( useNowAsDate ? now.getYear() : showMonthYear ? dateClock.getYear() : 1970, useNowAsDate ? now.getMonthOfYear() : showMonthYear ? dateClock.getMonth() + 1 : 1, useNowAsDate ? now.getDayOfMonth() : showDay ? dateClock.getDay() : 1, showTime ? timeClock.getHours() : 0, showTime ? timeClock.getMinutes() : 0, showTime ? timeClock.getSeconds() : 0, 0, DateTimeZone.getDefault() ); // Convert to UTC time for UTCTimestampT and UTCTimeOnlyT. // Performing UTCDateT and MonthYearT coversion could produce an unexpected result. // No conversion is needed for LocalMktTimeT, TZTimestampT, and TZTimeOnlyT. if ( parameter == null || parameter instanceof UTCTimestampT || parameter instanceof UTCTimeOnlyT ) { result = result.withZone( DateTimeZone.UTC ); logger.debug( "getControlValue() parameter: " + parameter + " result: " + result ); } return result; }
void preserveValues( final DateTime dateTime ) { ControlLCAUtil.preserveValues( dateTime ); IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); boolean hasListeners = SelectionEvent.hasListener( dateTime ); adapter.preserve( Props.SELECTION_LISTENERS, Boolean.valueOf( hasListeners ) ); adapter.preserve( PROP_HOURS, new Integer( dateTime.getHours() ) ); adapter.preserve( PROP_MINUTES, new Integer( dateTime.getMinutes() ) ); adapter.preserve( PROP_SECONDS, new Integer( dateTime.getSeconds() ) ); preserveSubWidgetsBounds( dateTime ); WidgetLCAUtil.preserveCustomVariant( dateTime ); }
@Override String getNameText() { return (style & SWT.TIME) != 0 ? getHours() + ":" + getMinutes() + ":" + getSeconds() : (getMonth() + 1) + "/" + getDay() + "/" + getYear(); }
String getNameText() { return (style & SWT.TIME) != 0 ? getHours() + ":" + getMinutes() + ":" + getSeconds() : (getMonth() + 1) + "/" + getDay() + "/" + getYear(); }
@Override String getNameText () { if (isTime ()) { return getHours () + ":" + getMinutes () + ":" + getSeconds (); } else { return (getMonth () + 1) + "/" + getDay () + "/" + getYear (); } }
@Override String getNameText () { if (isTime ()) { return getHours () + ":" + getMinutes () + ":" + getSeconds (); } else { return (getMonth () + 1) + "/" + getDay () + "/" + getYear (); } }
@Override String getNameText () { if (isTime ()) { return getHours () + ":" + getMinutes () + ":" + getSeconds (); } else { return (getMonth () + 1) + "/" + getDay () + "/" + getYear (); } }
@Override void preserveValues( DateTime dateTime ) { preserveProperty( dateTime, PROP_HOURS, dateTime.getHours() ); preserveProperty( dateTime, PROP_MINUTES, dateTime.getMinutes() ); preserveProperty( dateTime, PROP_SECONDS, dateTime.getSeconds() ); DateTimeLCAUtil.preserveSubWidgetsBounds( dateTime, getSubWidgetsBounds( dateTime ) ); DateTimeLCAUtil.preserveMinMaxLimit( dateTime ); }
cal.set(Calendar.MINUTE, startTime.getMinutes()); cal.set(Calendar.SECOND, startTime.getSeconds()); schedule.setRefreshStartTime(cal.getTime());
@Override void renderChanges( DateTime dateTime ) throws IOException { DateTimeLCAUtil.renderChanges( dateTime ); renderProperty( dateTime, PROP_HOURS, dateTime.getHours(), SWT.DEFAULT ); renderProperty( dateTime, PROP_MINUTES, dateTime.getMinutes(), SWT.DEFAULT ); renderProperty( dateTime, PROP_SECONDS, dateTime.getSeconds(), SWT.DEFAULT ); DateTimeLCAUtil.renderSubWidgetsBounds( dateTime, getSubWidgetsBounds( dateTime ) ); DateTimeLCAUtil.renderMinMaxLimit( dateTime ); }