org.joda.time.DateTime.withMillisOfSecond()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(124)

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

DateTime.withMillisOfSecond介绍

[英]Returns a copy of this datetime with the millis of second field updated.

DateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of millis of second changed.
[中]返回此日期时间的副本,并更新毫秒字段。
DateTime是不可变的,因此没有set方法。相反,此方法返回一个值为毫秒的新实例。

代码示例

代码示例来源:origin: Graylog2/graylog2-server

private static DateTime getDayBucket(DateTime observationTime) {
  return observationTime.withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
}

代码示例来源: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: dlew/joda-time-android

DateTime now = DateTime.now(time.getZone()).withMillisOfSecond(0);
DateTime timeDt = new DateTime(time).withMillisOfSecond(0);
boolean past = !now.isBefore(timeDt);
Duration duration = past ? new Duration(timeDt, now) : new Duration(now, timeDt);

代码示例来源:origin: apache/incubator-pinot

case MILLISECONDS:
 _dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter
   .print(dateTime.withMillisOfSecond((dateTime.getMillisOfSecond() / sz) * sz));
 break;
case SECONDS:

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

dt = dt.withSecondOfMinute(0);
default:
  dt = dt.withMillisOfSecond(0);
  break;

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

DateTime now = DateTime.now(time.getZone()).withMillisOfSecond(0);
DateTime timeDt = new DateTime(time).withMillisOfSecond(0);
boolean past = !now.isBefore(timeDt);
Interval interval = past ? new Interval(timeDt, now) : new Interval(now, timeDt);

代码示例来源:origin: rackerlabs/blueflood

private DateTime extractAndUpdateTime(DateTime inputDateTime) {
  DateTime resultDateTime = inputDateTime.withSecondOfMinute(0).withMillisOfSecond(0);
  if (dateTime.equals("") || dateTime.contains("now"))
    return resultDateTime;
  int hour = 0;
  int minute = 0;
  Pattern p = Pattern.compile("(\\d{1,2}):(\\d{2})([a|p]m)?(.*)");
  Matcher m = p.matcher(dateTime);
  if (m.matches()) {
    hour = Integer.parseInt(m.group(1));
    minute = Integer.parseInt(m.group(2));
    String middayModifier = m.group(3);
    if (middayModifier != null && middayModifier.equals("pm"))
      hour = (hour + 12) % 24;
    dateTime = m.group(4);
  }
  if (dateTime.contains("noon")) {
    hour = 12;
    dateTime = dateTime.replace("noon", "");
  }
  else if (dateTime.contains("teatime")) {
    hour = 16;
    dateTime = dateTime.replace("teatime", "");
  } else if (dateTime.contains("midnight"))
    dateTime = dateTime.replace("midnight", "");
  return resultDateTime.withHourOfDay(hour).withMinuteOfHour(minute);
}

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

result = result.withMillisOfSecond(0);
assertFunction("date_trunc('second', " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(result, session));
result = result.withMillisOfSecond(0);
assertFunction("date_trunc('second', " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(result));

代码示例来源:origin: rackerlabs/blueflood

private static DateTime nowDateTime() {
  return new DateTime().withSecondOfMinute(0).withMillisOfSecond(0);
}

代码示例来源:origin: rackerlabs/blueflood

@Before
public void setup() {
  nowDateTime = new DateTime().withSecondOfMinute(0).withMillisOfSecond(0);
}

代码示例来源:origin: rackerlabs/blueflood

private static DateTime referenceDateTime() {
  return new DateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
}

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

protected DateTime now() {
    DateTime dt = highPrecision ? DateTime.now() : DateTime.now().withMillisOfSecond(0);
    return 0 == delta ? dt : dt.plusSeconds(delta);
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

@Override
  public long applyAsLong(long operand) {
    return new DateTime(operand,tz).withMillisOfSecond(0).withSecondOfMinute(0).getMillis();
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-basics

@Override
  public long applyAsLong(long operand) {
    return new DateTime(operand,tz).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).getMillis();
  }
}

代码示例来源:origin: plusonelabs/calendar-widget

public static Intent createNewEventIntent(DateTimeZone timeZone) {
    DateTime beginTime = new DateTime(timeZone).plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0)
        .withMillisOfSecond(0);
    DateTime endTime = beginTime.plusHours(1);
    return new Intent(Intent.ACTION_INSERT, Events.CONTENT_URI)
        .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getMillis())
        .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getMillis());
  }
}

代码示例来源:origin: FINRAOS/herd

/**
 * Returns a random timestamp.
 */
public static DateTime getRandomDateTime()
{
  return new DateTime(new Random().nextLong()).withMillisOfSecond(0);
}

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

/**
 * Parse the to date query param.
 */
private DateTime parseFromDate(String fromDate) {
  // Default to the last 30 days
  DateTime defaultFrom = new DateTime().withZone(DateTimeZone.UTC).minusDays(30).withHourOfDay(0)
      .withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
  return parseDate(fromDate, defaultFrom, true);
}

代码示例来源:origin: org.alfresco/alfresco-repository

@Override
public int getDuration(DateTime now, DateTime expiryDate)
{
  Interval interval = new Interval(now.withMillisOfSecond(0), expiryDate);
  return interval.toPeriod(PeriodType.minutes()).getMinutes();
}

代码示例来源: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;
}

代码示例来源:origin: org.jruby/jruby-complete

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

相关文章

DateTime类方法