本文整理了Java中org.joda.time.DateTime.getSecondOfMinute()
方法的一些代码示例,展示了DateTime.getSecondOfMinute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.getSecondOfMinute()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:getSecondOfMinute
暂无
代码示例来源:origin: Graylog2/graylog2-server
private static Map<String, Object> ingestTimeFields(DateTime ingestTime) {
return ImmutableMap.<String, Object>builder()
.put("ingest_time", ingestTime.toString())
.put("ingest_time_epoch", ingestTime.getMillis())
.put("ingest_time_second", ingestTime.getSecondOfMinute())
.put("ingest_time_minute", ingestTime.getMinuteOfHour())
.put("ingest_time_hour", ingestTime.getHourOfDay())
.put("ingest_time_day", ingestTime.getDayOfMonth())
.put("ingest_time_month", ingestTime.getMonthOfYear())
.put("ingest_time_year", ingestTime.getYear())
.build();
}
代码示例来源:origin: alibaba/canal
dateTime = new DateTime(((Date) val).getTime());
if (dateTime.getHourOfDay() == 0 && dateTime.getMinuteOfHour() == 0 && dateTime.getSecondOfMinute() == 0
&& dateTime.getMillisOfSecond() == 0) {
res = dateTime.toString("yyyy-MM-dd");
if (dateTime.getHourOfDay() == 0 && dateTime.getMinuteOfHour() == 0 && dateTime.getSecondOfMinute() == 0
&& dateTime.getMillisOfSecond() == 0) {
res = dateTime.toString("yyyy-MM-dd");
代码示例来源:origin: apache/incubator-gobblin
@Override
public void run() {
DescriptiveStatistics stats = this.limiter.getRateStatsSinceLastReport();
long now = System.currentTimeMillis();
this.runs++;
if (stats != null) {
long key;
if (this.relativeKey) {
key = 15 * this.runs;
} else {
DateTime nowTime = new DateTime(now).withMillisOfSecond(0);
DateTime rounded = nowTime.withSecondOfMinute(15 * (nowTime.getSecondOfMinute() / 15));
key = rounded.getMillis() / 1000;
}
try {
this.context.write(new LongWritable(key), new DoubleWritable(stats.getSum()));
} catch (IOException | InterruptedException ioe) {
log.error("Error: ", ioe);
}
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public void doRun() {
final DateTime now = Tools.nowUTC();
final int secondOfMinute = now.getSecondOfMinute();
// on the top of every minute, we flush the current throughput
if (secondOfMinute == 0) {
LOG.trace("Calculating input and output traffic for the previous minute");
final long currentInputBytes = inputCounter.getCount();
final long currentOutputBytes = outputCounter.getCount();
final long currentDecodedBytes = decodedCounter.getCount();
final long inputLastMinute = currentInputBytes - previousInputBytes;
previousInputBytes = currentInputBytes;
final long outputBytesLastMinute = currentOutputBytes - previousOutputBytes;
previousOutputBytes = currentOutputBytes;
final long decodedBytesLastMinute = currentDecodedBytes - previousDecodedBytes;
previousDecodedBytes = currentDecodedBytes;
if (LOG.isDebugEnabled()) {
final Size in = Size.bytes(inputLastMinute);
final Size out = Size.bytes(outputBytesLastMinute);
final Size decoded = Size.bytes(decodedBytesLastMinute);
LOG.debug("Traffic in the last minute: in: {} bytes ({} MB), out: {} bytes ({} MB}), decoded: {} bytes ({} MB})",
in, in.toMegabytes(), out, out.toMegabytes(), decoded, decoded.toMegabytes());
}
final DateTime previousMinute = now.minusMinutes(1);
trafficService.updateTraffic(previousMinute, nodeId, inputLastMinute, outputBytesLastMinute, decodedBytesLastMinute);
}
}
代码示例来源:origin: apache/incubator-pinot
case SECONDS:
_dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter.print(
dateTime.withSecondOfMinute((dateTime.getSecondOfMinute() / sz) * sz).secondOfMinute().roundFloorCopy());
break;
case MINUTES:
代码示例来源:origin: apache/drill
@Test
public void testTimeHoursMinutesSecondsFormat() {
int hours = 11;
int minutes = 50;
String seconds = "05";
DateTime date = parseDateFromPostgres(hours + ":" + minutes + ":" + seconds + " am", "hh12:mi:ss am");
Assert.assertTrue(date.getHourOfDay() == hours &&
date.getMinuteOfHour() == minutes &&
date.getSecondOfMinute() == Integer.parseInt(seconds));
}
代码示例来源:origin: apache/drill
@Test
public void testTimeHours24MinutesSecondsFormat() {
int hours = 15;
int minutes = 50;
int seconds = 5;
DateTime date = parseDateFromPostgres(hours + ":" + minutes + ":" + seconds, "hh24:mi:ss");
Assert.assertTrue(date.getHourOfDay() == hours &&
date.getMinuteOfHour() == minutes &&
date.getSecondOfMinute() == seconds);
}
代码示例来源:origin: prestodb/presto
@Test
public void testExtractFromTimestamp()
assertFunction("extract(second FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getSecondOfMinute());
assertFunction("extract(minute FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getMinuteOfHour());
assertFunction("extract(hour FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getHourOfDay());
assertFunction("extract(year FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getYear());
assertFunction("extract(second FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getSecondOfMinute());
assertFunction("extract(minute FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getMinuteOfHour());
assertFunction("extract(hour FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getHourOfDay());
代码示例来源:origin: HubSpot/Singularity
public Date getNextValidTime() {
final long now = System.currentTimeMillis();
DateTime startDateTime = new DateTime(dtStart.getYear(), (dtStart.getMonthOfYear() - 1), dtStart.getDayOfMonth(),
dtStart.getHourOfDay(), dtStart.getMinuteOfHour(), dtStart.getSecondOfMinute());
RecurrenceRuleIterator timeIterator = recurrenceRule.iterator(startDateTime);
int count = 0;
while (timeIterator.hasNext() && (count < MAX_ITERATIONS || (recurrenceRule.hasPart(Part.COUNT) && count < recurrenceRule.getCount()))) {
count ++;
long nextRunAtTimestamp = timeIterator.nextMillis();
if (nextRunAtTimestamp >= now) {
return new Date(nextRunAtTimestamp);
}
}
return null;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
bucket.saveField(DateTimeFieldType.hourOfDay(), dt.getHourOfDay());
bucket.saveField(DateTimeFieldType.minuteOfHour(), dt.getMinuteOfHour());
bucket.saveField(DateTimeFieldType.secondOfMinute(), dt.getSecondOfMinute());
bucket.saveField(DateTimeFieldType.millisOfSecond(), dt.getMillisOfSecond());
bucket.setZone(DateTimeZone.UTC);
代码示例来源:origin: org.jruby/jruby-complete
/**
* @return second-of-minute
*/
public int getSecond() { return dt.getSecondOfMinute(); }
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*/
public int getSecondOfMinute() {
return this.instance.getSecondOfMinute();
}
代码示例来源:origin: org.jruby/jruby-core
/**
* @return second-of-minute
* @since 9.2
*/
public int getSecond() { return dt.getSecondOfMinute(); }
代码示例来源:origin: actiontech/dble
/**
* getSecond
*
* @param date
* @return
*/
public static int getSecond(Date date) {
DateTime dt = new DateTime(date);
return dt.getSecondOfMinute();
}
代码示例来源:origin: metatron-app/metatron-discovery
private List<DateTime> getSecondLabels(DateTime min, DateTime max, int unitSize) {
List<DateTime> labels = new ArrayList<>();
DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
min.getHourOfDay(), min.getMinuteOfHour(), min.getSecondOfMinute() / unitSize * unitSize);
while (dt.isBefore(max) || dt.isEqual(max)) {
labels.add(dt);
dt = dt.plusSeconds(unitSize);
}
labels.add(dt);
return labels;
}
代码示例来源:origin: metatron-app/metatron-discovery
private List<DateTime> getMillisLabels(DateTime min, DateTime max, int unitSize) {
List<DateTime> labels = new ArrayList<>();
DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
min.getHourOfDay(), min.getMinuteOfHour(), min.getSecondOfMinute(), min.getMillisOfSecond() / unitSize * unitSize);
while (dt.isBefore(max) || dt.isEqual(max)) {
labels.add(dt);
dt = dt.plusMillis(unitSize);
}
labels.add(dt);
return labels;
}
代码示例来源:origin: openEHR/java-libs
public static DateTime defaultTime() {
DateTime time = new DateTime();
return new DateTime(1970, 1, 1, time.getHourOfDay(), time.getMinuteOfHour(),
time.getSecondOfMinute(), time.getMillisOfSecond());
}
代码示例来源:origin: org.apache.isis.core/isis-core-applib
/**
* Create a Time object for storing a time with the time set to the
* specified time of the Joda Time DateTime object.
*/
public Time(final DateTime dateTime) {
this.time = newDateTime(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute());
}
代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-core-test
@Test
public void testCronEveryFiveMinutes() {
final Date nextRunTime = calculateNextRunTime(forCronExpression("0 */5 * * * ?"));
assertThat(nextRunTime, not(nullValue()));
final DateTime dateTime = new DateTime(nextRunTime);
if (dateTime.getMillisOfSecond() != 0
|| dateTime.getSecondOfMinute() != 0
|| (dateTime.getMinuteOfHour() % 5) != 0) {
fail("Should have fallen on a 5 minute boundary: " + dateTime);
}
}
代码示例来源:origin: org.jruby/jruby-core
private static RubyDateTime calcAjdFromCivil(ThreadContext context, final DateTime dt, final int off,
final long subMillisNum, final long subMillisDen) {
final Ruby runtime = context.runtime;
long jd = civil_to_jd(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), ITALY);
RubyNumeric fr = timeToDayFraction(context, dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute());
final RubyNumeric ajd = jd_to_ajd(context, jd, fr, off);
RubyDateTime dateTime = new RubyDateTime(context, getDateTime(runtime), ajd, off, ITALY);
dateTime.dt = dateTime.dt.withMillisOfSecond(dt.getMillisOfSecond());
dateTime.subMillisNum = subMillisNum; dateTime.subMillisDen = subMillisDen;
return dateTime;
}
内容来源于网络,如有侵权,请联系作者删除!