org.eclipse.swt.widgets.DateTime.getHours()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(217)

本文整理了Java中org.eclipse.swt.widgets.DateTime.getHours()方法的一些代码示例,展示了DateTime.getHours()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.getHours()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.DateTime
类名称:DateTime
方法名:getHours

DateTime.getHours介绍

[英]Returns the receiver's hours.

Hours is an integer between 0 and 23.
[中]返回接收者的小时数。
小时是介于0和23之间的整数。

代码示例

代码示例来源:origin: org.xworker/xworker_swt

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);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.databinding

@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();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

private void writeHours( final DateTime dateTime ) throws IOException {
 Integer newValue = new Integer( dateTime.getHours() );
 if( WidgetLCAUtil.hasChanged( dateTime, PROP_HOURS, newValue ) ) {
  JSWriter writer = JSWriter.getWriterFor( dateTime );
  writer.set( PROP_HOURS, newValue );
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

int getArrow (int /*long*/ widget) {
  int adj_value = (int) OS.gtk_adjustment_get_value (OS.gtk_spin_button_get_adjustment (widget));
  int new_value = 0;
    if (isDate ()) {
      // getMonth () return 0 as first month and 11 as last one, whereas adjusment does not, so adding one makes them comaprable
      new_value = getMonth ()+1;
    } else if (isTime ()) {
    // as getHours () has 24h format but spinner 12h format, new_value needs to be converted to 12h format
      if (getHours () > 12 ){
        new_value = getHours () - 12;
      } else {
        new_value = getHours ();
        // This fix does not compares adj_value to new_value when getArrow is called on widget creation
      }
      if (new_value == 0) new_value = 12;
    }
    if (adj_value == 0 && firstTime)
      return 0;
    firstTime = false;
    if ( adj_value == new_value) return 0;
  return adj_value > new_value ? SWT.ARROW_UP : SWT.ARROW_DOWN;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

int getArrow (int /*long*/ widget) {
  int adj_value = (int) OS.gtk_adjustment_get_value (OS.gtk_spin_button_get_adjustment (widget));
  int new_value = 0;
    if (isDate ()) {
      // getMonth () return 0 as first month and 11 as last one, whereas adjusment does not, so adding one makes them comaprable
      new_value = getMonth ()+1;
    } else if (isTime ()) {
    // as getHours () has 24h format but spinner 12h format, new_value needs to be converted to 12h format
      if (getHours () > 12 ){
        new_value = getHours () - 12;
      } else {
        new_value = getHours ();
        // This fix does not compares adj_value to new_value when getArrow is called on widget creation
      }
      if (new_value == 0) new_value = 12;
    }
    if (adj_value == 0 && firstTime)
      return 0;
    firstTime = false;
    if ( adj_value == new_value) return 0;
  return adj_value > new_value ? SWT.ARROW_UP : SWT.ARROW_DOWN;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

int getArrow (long /*int*/ widget) {
  int adj_value = (int) OS.gtk_adjustment_get_value (OS.gtk_spin_button_get_adjustment (widget));
  int new_value = 0;
    if (isDate ()) {
      // getMonth () return 0 as first month and 11 as last one, whereas adjusment does not, so adding one makes them comaprable
      new_value = getMonth ()+1;
    } else if (isTime ()) {
    // as getHours () has 24h format but spinner 12h format, new_value needs to be converted to 12h format
      if (getHours () > 12 ){
        new_value = getHours () - 12;
      } else {
        new_value = getHours ();
        // This fix does not compares adj_value to new_value when getArrow is called on widget creation
      }
      if (new_value == 0) new_value = 12;
    }
    if (adj_value == 0 && firstTime)
      return 0;
    firstTime = false;
    if ( adj_value == new_value) return 0;
  return adj_value > new_value ? SWT.ARROW_UP : SWT.ARROW_DOWN;
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

/**
 * 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();
 }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

/**
 * Sets the receiver's minutes.
 * <p>
 * Minutes is an integer between 0 and 59.
 * </p>
 *
 * @param minutes 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 setMinutes( int minutes ) {
 checkWidget();
 if( checkTime( getHours(), minutes, getSeconds() ) ) {
  rightNow.set( Calendar.MINUTE, minutes );
  applyLimits();
 }
}

代码示例来源:origin: atdl4j/atdl4j

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;
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

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 );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

@Override
String getNameText() {
  return (style & SWT.TIME) != 0 ? getHours() + ":" + getMinutes() + ":" + getSeconds()
      : (getMonth() + 1) + "/" + getDay() + "/" + getYear();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

@Override
String getNameText () {
  if (isTime ()) {
    return getHours () + ":" + getMinutes () + ":" + getSeconds ();
  } else {
    return (getMonth () + 1) + "/" + getDay () + "/" + getYear ();
  }
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

String getNameText() {
  return (style & SWT.TIME) != 0 ? getHours() + ":" + getMinutes() + ":" + getSeconds()
      : (getMonth() + 1) + "/" + getDay() + "/" + getYear();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

@Override
String getNameText () {
  if (isTime ()) {
    return getHours () + ":" + getMinutes () + ":" + getSeconds ();
  } else {
    return (getMonth () + 1) + "/" + getDay () + "/" + getYear ();
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

@Override
String getNameText () {
  if (isTime ()) {
    return getHours () + ":" + getMinutes () + ":" + getSeconds ();
  } else {
    return (getMonth () + 1) + "/" + getDay () + "/" + getYear ();
  }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

@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 );
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.team.ui

cal.set(Calendar.HOUR_OF_DAY, startTime.getHours());
cal.set(Calendar.MINUTE, startTime.getMinutes());
cal.set(Calendar.SECOND, startTime.getSeconds());

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

@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 );
}

相关文章

DateTime类方法