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

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

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

DateTime.withSecondOfMinute介绍

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

DateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of second of minute changed.
[中]返回此datetime的副本,其中“分钟数”字段已更新。
DateTime是不可变的,因此没有set方法。相反,此方法返回一个值为second of minute changed的新实例。

代码示例

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

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

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

private DateTime parseDateTime(final String scheduleDate, final String scheduleTime) {
 // scheduleTime: 12,00,pm,PDT
 final String[] parts = scheduleTime.split(",", -1);
 int hour = Integer.parseInt(parts[0]);
 final int minutes = Integer.parseInt(parts[1]);
 final boolean isPm = parts[2].equalsIgnoreCase("pm");
 final DateTimeZone timezone =
   parts[3].equals("UTC") ? DateTimeZone.UTC : DateTimeZone.getDefault();
 // scheduleDate: 02/10/2013
 DateTime day = null;
 if (scheduleDate == null || scheduleDate.trim().length() == 0) {
  day = new LocalDateTime().toDateTime();
 } else {
  day = DateTimeFormat.forPattern("MM/dd/yyyy")
    .withZone(timezone).parseDateTime(scheduleDate);
 }
 hour %= 12;
 if (isPm) {
  hour += 12;
 }
 final DateTime firstSchedTime =
   day.withHourOfDay(hour).withMinuteOfHour(minutes).withSecondOfMinute(0);
 return firstSchedTime;
}

代码示例来源: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: apache/incubator-pinot

case SECONDS:
 _dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter.print(
   dateTime.withSecondOfMinute((dateTime.getSecondOfMinute() / sz) * sz).secondOfMinute().roundFloorCopy());
 break;
case MINUTES:

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

dt = dt.withHourOfDay(0);
  dt = dt.withMinuteOfHour(0);
  dt = dt.withSecondOfMinute(0);
default:
  dt = dt.withMillisOfSecond(0);

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

queryStr = StringUtils.replace(queryStr, "%%POST_AG_REQUEST_START%%", INTERVAL_FMT.print(dtFirst));
queryStr = StringUtils.replace(queryStr, "%%POST_AG_REQUEST_END%%", INTERVAL_FMT.print(dtLast.plusMinutes(2)));
String postAgResponseTimestamp = TIMESTAMP_FMT.print(dtGroupBy.withSecondOfMinute(0));
queryStr = StringUtils.replace(queryStr, "%%POST_AG_RESPONSE_TIMESTAMP%%", postAgResponseTimestamp);
queryStr = StringUtils.replace(queryStr, "%%DATASOURCE%%", fullDatasourceName);

代码示例来源:origin: HubSpot/Singularity

public RFC5545Schedule(String schedule) throws InvalidRecurrenceRuleException {
 // DTSTART is RFC5545 but NOT in the recur string, but its a nice to have? :)
 Pattern pattern = Pattern.compile("DTSTART=([0-9]{8}T[0-9]{6})");
 Matcher matcher = pattern.matcher(schedule);
 if (matcher.find()) {
  DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss");
  this.dtStart = formatter.parseDateTime(matcher.group(1));
  this.recurrenceRule = new RecurrenceRule(matcher.replaceAll("").replace("RRULE:", ""));
 } else {
  this.recurrenceRule = new RecurrenceRule(schedule);
  this.dtStart = org.joda.time.DateTime.now().withSecondOfMinute(0);
 }
}

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

assertFunction("date_trunc('second', " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(result, session));
result = result.withSecondOfMinute(0);
assertFunction("date_trunc('minute', " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(result, session));
assertFunction("date_trunc('second', " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(result));
result = result.withSecondOfMinute(0);
assertFunction("date_trunc('minute', " + 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: openimaj/openimaj

@Override
  public LongLongPair startEnd(long time) {
    DateTime dt = new DateTime(time);
    DateTime start = dt.withSecondOfMinute(0);
    DateTime end = dt.plus(minutePeriod).withSecondOfMinute(0);
    
    return LongLongPair.pair(start.getMillis(), end.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: qcadoo/mes

private Interval extractSearchInterval(final Entity contextEntity) {
  Date from = contextEntity.getDateField(BalanceContextFields.FROM_DATE);
  Date to = contextEntity.getDateField(BalanceContextFields.TO_DATE);
  DateTime toMidnight = new DateTime(to).withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59);
  return new Interval(new DateTime(from), toMidnight);
}

代码示例来源: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: io.apiman/apiman-manager-api-rest-impl

/**
 * 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
int getDuration(DateTime now, DateTime expiryDate)
{
  Interval interval = new Interval(now.withSecondOfMinute(0).withMillisOfSecond(0), expiryDate);
  return interval.toPeriod(PeriodType.days()).getDays();
}

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

@Override
int getDuration(DateTime now, DateTime expiryDate)
{
  Interval interval = new Interval(now.withSecondOfMinute(0).withMillisOfSecond(0), expiryDate);
  return interval.toPeriod(PeriodType.hours()).getHours();
}

相关文章

DateTime类方法