java.util.Date.getSeconds()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(237)

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

Date.getSeconds介绍

[英]Returns the gregorian calendar second of the minute for this Date object.
[中]返回此日期对象的公历每分钟的第二秒。

代码示例

代码示例来源:origin: prestodb/presto

/**
 * Constructs a TimeOfDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the TimeOfDay.
 * This is useful to ensure that the field values are the same in the
 * created TimeOfDay no matter what the time zone is. For example, if
 * the Calendar states that the time is 04:29, then the created TimeOfDay
 * will always have the time 04:29 irrespective of time zone issues.
 * <p>
 * This factory method always creates a TimeOfDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created TimeOfDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static TimeOfDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new TimeOfDay(
    date.getHours(),
    date.getMinutes(),
    date.getSeconds(),
    (((int) (date.getTime() % 1000)) + 1000) % 1000
  );
}

代码示例来源:origin: stackoverflow.com

java.sql.Time sqlTime = new java.sql.Time(1,0,0);
LocalTime localTime = new LocalTime(sqlTime.getHours(), sqlTime.getMinues(), sqlTime.getSeconds());

代码示例来源:origin: stackoverflow.com

You can use below code to run TimerTask every hours HH:00:-
Timer timer = new Timer();
    Calendar cd = Calendar.getInstance();
    Date dt = cd.getTime();
    long mmss = dt.getMinutes() * 60 + dt.getSeconds();
    long remTime = 60 * 60 * 60 - mmss;

    timer.scheduleAtFixedRate(new TimerTask() {

      @Override
      public void run() {
        // TODO Auto-generated method stub

      }
    }, remTime * 1000, 60*60 * 60 * 1000);

代码示例来源:origin: prestodb/presto

date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
  (((int) (date.getTime() % 1000)) + 1000) % 1000
);

代码示例来源:origin: stackoverflow.com

Timer t=new Timer();
   t.schedule(new TimerTask() {
     @Override
     public void run() {
       final Date d = new Date();
       runOnUiThread(new Runnable() {
         @Override
         public void run() {
           textView.setText(d.getMinutes() +":" + d.getSeconds());
         }
       });
     }
   }, 0,1000);

代码示例来源:origin: com.jtransc/jtransc-rt

@Deprecated
@JTranscMethodBody(target = "js", value = "this._date.setMinutes(p0);")
public void setMinutes(int minutes) {
  this.setTimestamp(JTranscTime.make(getFullYear(), getMonth(), getDate(), getHours(), minutes, getSeconds(), getMilliseconds()));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Constructs a TimeOfDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the TimeOfDay.
 * This is useful to ensure that the field values are the same in the
 * created TimeOfDay no matter what the time zone is. For example, if
 * the Calendar states that the time is 04:29, then the created TimeOfDay
 * will always have the time 04:29 irrespective of time zone issues.
 * <p>
 * This factory method always creates a TimeOfDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created TimeOfDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static TimeOfDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new TimeOfDay(
    date.getHours(),
    date.getMinutes(),
    date.getSeconds(),
    (((int) (date.getTime() % 1000)) + 1000) % 1000
  );
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Deprecated
@JTranscMethodBody(target = "js", value = "this._date.setHours(p0);")
public void setHours(int hours) {
  this.setTimestamp(JTranscTime.make(getFullYear(), getMonth(), getDate(), hours, getMinutes(), getSeconds(), getMilliseconds()));
}

代码示例来源:origin: joda-time/joda-time

date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
  (((int) (date.getTime() % 1000)) + 1000) % 1000
);

代码示例来源:origin: JodaOrg/joda-time

/**
 * Constructs a TimeOfDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the TimeOfDay.
 * This is useful to ensure that the field values are the same in the
 * created TimeOfDay no matter what the time zone is. For example, if
 * the Calendar states that the time is 04:29, then the created TimeOfDay
 * will always have the time 04:29 irrespective of time zone issues.
 * <p>
 * This factory method always creates a TimeOfDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created TimeOfDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static TimeOfDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new TimeOfDay(
    date.getHours(),
    date.getMinutes(),
    date.getSeconds(),
    (((int) (date.getTime() % 1000)) + 1000) % 1000
  );
}

代码示例来源:origin: JodaOrg/joda-time

date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
  (((int) (date.getTime() % 1000)) + 1000) % 1000
);

代码示例来源:origin: prestodb/presto

date.getMonth() + 1,
  date.getDate(),
  date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
  (((int) (date.getTime() % 1000)) + 1000) % 1000
);

代码示例来源:origin: joda-time/joda-time

date.getMonth() + 1,
  date.getDate(),
  date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
  (((int) (date.getTime() % 1000)) + 1000) % 1000
);

代码示例来源:origin: com.alibaba/fastjson

@SuppressWarnings("deprecation")
  public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
    if (object == null) {
      serializer.out.writeNull();
      return;
    }
    
    Date date = (Date) object;
        JSONObject json = new JSONObject();
    json.put("date", date.getDate());
    json.put("day", date.getDay());
    json.put("hours", date.getHours());
    json.put("minutes", date.getMinutes());
    json.put("month", date.getMonth());
    json.put("seconds", date.getSeconds());
    json.put("time", date.getTime());
    json.put("timezoneOffset", date.getTimezoneOffset());
    json.put("year", date.getYear());

    serializer.write(json);
  }
}

代码示例来源:origin: h2oai/h2o-3

/**
 * Instantiate an AutoML object and start it running.  Progress can be tracked via its job().
 *
 * @param buildSpec
 * @return
 */
public static AutoML startAutoML(AutoMLBuildSpec buildSpec) {
 Date startTime = new Date();  // this is the one and only startTime for this run
 synchronized (AutoML.class) {
  // protect against two runs whose startTime is the same second
  if (lastStartTime != null) {
   while (lastStartTime.getYear() == startTime.getYear() &&
       lastStartTime.getMonth() == startTime.getMonth() &&
       lastStartTime.getDate() == startTime.getDate() &&
       lastStartTime.getHours() == startTime.getHours() &&
       lastStartTime.getMinutes() == startTime.getMinutes() &&
       lastStartTime.getSeconds() == startTime.getSeconds())
    startTime = new Date();
  }
  lastStartTime = startTime;
 }
 String keyString = buildSpec.build_control.project_name;
 AutoML aml = AutoML.makeAutoML(Key.<AutoML>make(keyString), startTime, buildSpec);
 DKV.put(aml);
 startAutoML(aml);
 return aml;
}

代码示例来源:origin: JodaOrg/joda-time

date.getMonth() + 1,
  date.getDate(),
  date.getHours(),
  date.getMinutes(),
  date.getSeconds(),
  (((int) (date.getTime() % 1000)) + 1000) % 1000
);

代码示例来源:origin: stackoverflow.com

System.out.println("only begin time of events="+begin.getHours() + ":" +begin.getMinutes() + ":" +begin.getSeconds());
System.out.println("only begin time of events="+end.getHours() + ":" +end.getMinutes() + ":" +end.getSeconds());
beg_time = begin.getHours();

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

date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
nanosOfSecond);

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

long millis = (int)(date.getTime() % Conversions.MILLISECONDS_PER_SECOND);
int nanosOfSecond = (int)(millis * Conversions.NANOSECONDS_PER_MILLISECOND);
return LocalTime.of(date.getHours(),
          date.getMinutes(),
          date.getSeconds(),
          nanosOfSecond);

代码示例来源:origin: stackoverflow.com

Date dob=null;
DateFormat df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
dob=df.parse( "2014-02-10 11:15:00" );
GregorianCalendar cal = new GregorianCalendar();

cal.setTime(dob);
XMLGregorianCalendar xmlDate2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH), dob.getHours(),dob.getMinutes(),dob.getSeconds(),DatatypeConstants.FIELD_UNDEFINED, cal.getTimeZone().LONG).normalize();
XMLGregorianCalendar xmlDate3 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH),dob.getHours(),dob.getMinutes(),dob.getSeconds(),DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);
System.out.println(xmlDate2);
System.out.println(xmlDate3);

相关文章