本文整理了Java中org.joda.time.DateTime.minusMillis()
方法的一些代码示例,展示了DateTime.minusMillis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.minusMillis()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:minusMillis
[英]Returns a copy of this datetime minus the specified number of millis.
The calculation will subtract a duration equivalent to the number of milliseconds.
The following three lines are identical in effect:
DateTime subtracted = dt.minusMillis(6);
DateTime subtracted = dt.minus(Period.millis(6));
DateTime subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6);
This datetime instance is immutable and unaffected by this method call.
[中]返回此datetime减去指定毫秒数的副本。
该计算将减去相当于毫秒数的持续时间。
以下三行实际上是相同的:
DateTime subtracted = dt.minusMillis(6);
DateTime subtracted = dt.minus(Period.millis(6));
DateTime subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6);
此datetime实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: apache/incubator-druid
@Test
public void testUsedWithinBoundsEnd() throws IOException
{
coordinator.announceHistoricalSegments(SEGMENTS);
Assert.assertEquals(
SEGMENTS,
ImmutableSet.copyOf(
coordinator.getUsedSegmentsForInterval(
defaultSegment.getDataSource(),
defaultSegment.getInterval().withEnd(defaultSegment.getInterval().getEnd().minusMillis(1))
)
)
);
}
代码示例来源:origin: stackoverflow.com
DateTime first = new DateTime(larger-time);
DateTime second = new DateTime(smaller-time);
DateTime difference = first.minusMillis(second.getMillis())
代码示例来源:origin: facebook/jcommon
@Test(groups = "fast")
public void testFallOff() throws Exception {
EventCounter firstCounter = nextEventWindow(1);
CompositeEventCounterIf<EventCounter> counter =
newCompositeEventCounter(Duration.standardMinutes(3))
.addEventCounter(firstCounter);
// single element set
counter.add(100);
Assert.assertEquals(firstCounter.getValue(), counter.getValue());
EventCounter middleCounter = nextEventWindow(2);
counter.addEventCounter(middleCounter);
// now has two elements
middleCounter.add(1000);
setNow(middleCounter.getEnd());
Assert.assertEquals(counter.getValue(), 1100);
// add one more
EventCounter lastCounter = nextEventWindow(1);
counter.addEventCounter(lastCounter);
setNow(lastCounter.getEnd().toDateTime().minusMillis(1));
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
Assert.assertEquals(counter.getValue(), 1001);
// test updating last counter
lastCounter.add(200);
Assert.assertEquals(counter.getValue(), 1201);
counter.add(5);
Assert.assertEquals(lastCounter.getValue(), 205);
Assert.assertEquals(counter.getValue(), 1206);
}
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*
* @see org.modeshape.graph.property.DateTime#minusMillis(int)
*/
public org.modeshape.graph.property.DateTime minusMillis( int milliseconds ) {
return new JodaDateTime(this.instance.minusMillis(milliseconds));
}
代码示例来源:origin: com.atlassian.plugins/base-hipchat-integration-plugin-api
@VisibleForTesting
boolean isExpired(Date tokenExpiryDate) {
return tokenExpiryDate == null ||
new DateTime(tokenExpiryDate).minusMillis((int) EXPIRE_TIME_BUFFER_MILLIS).isBeforeNow();
}
代码示例来源:origin: openmainframeproject/ade
/**
* Return the end of day of yesterday
* @param dateTime
* @return
*/
private DateTime getYesterdayEndOfDay(DateTime dateTime) {
dateTime = dateTime.withTimeAtStartOfDay();
dateTime = dateTime.minusMillis(1);
return dateTime;
}
代码示例来源:origin: org.kill-bill.commons/killbill-queue
private Date getReapingDate() {
return clock.getUTCNow().minusMillis((int) pendingPeriod).toDate();
}
};
代码示例来源:origin: stackoverflow.com
clearMilis(date1).compareTo(clearMilis(date2))
/**
* @param date date
*
* @return truncated miliseconds
*/
@Nonnull
public static Date clearMillis(final @Nonnull Date date)
{
DateTime result = new DateTime(date);
return result.minusMillis(result.getMillisOfSecond()).toDate();
}
代码示例来源:origin: qcadoo/mes
public static DateTime getDefaultDateTo() {
return DateTime.now().withTimeAtStartOfDay().plusDays(1).minusMillis(1);
}
代码示例来源:origin: seemoo-lab/fitness-app
public static DateTime roundToSeconds(DateTime dateTime) {
return dateTime.minusMillis(dateTime.getMillisOfSecond());
}
代码示例来源:origin: 3zamn/kingMicro
public static Date getEndOfDay(){
return new DateTime().plusDays(1).withTimeAtStartOfDay().minusMillis(1).toDate();
}
代码示例来源:origin: stackoverflow.com
import java.util.*;
import org.joda.time.*;
public class ChinaTest {
public static void main(String[] args) {
DateTime startOf1900 = new DateTime(1900, 1, 1, 0, 0, 0, DateTimeZone.UTC);
DateTime endOf1899 = startOf1900.minusMillis(1);
DateTimeZone jodaZone = DateTimeZone.forID("Asia/Shanghai");
System.out.println("Joda at start of 1900: " +
jodaZone.getOffset(startOf1900));
System.out.println("Joda at end of 1899: " +
jodaZone.getOffset(endOf1899));
TimeZone javaZone = TimeZone.getTimeZone("Asia/Shanghai");
System.out.println("Java at start of 1900: " +
javaZone.getOffset(startOf1900.getMillis()));
System.out.println("Java at end of 1899: " +
javaZone.getOffset(startOf1900.getMillis() - 1));
}
}
代码示例来源:origin: metatron-app/metatron-discovery
public DateTime atEndDateTime(DateTime dateTime) {
switch (this) {
case YEAR:
return atStartDateTime(dateTime.plusYears(1)).minusMillis(1);
case MONTH:
return atStartDateTime(dateTime.plusMonths(1)).minusMillis(1);
case WEEK:
return atStartDateTime(dateTime.plusWeeks(1)).minusMillis(1);
case DAY:
return atStartDateTime(dateTime.plusDays(1)).minusMillis(1);
}
return dateTime;
}
}
代码示例来源:origin: spring-projects/spring-security-saml
protected boolean isDateTimeSkewValid(int skewMillis, int forwardMillis, DateTime time) {
if (time == null) {
return false;
}
final DateTime reference = new DateTime();
final Interval validTimeInterval = new Interval(
reference.minusMillis(skewMillis + forwardMillis),
reference.plusMillis(skewMillis)
);
return validTimeInterval.contains(time);
}
代码示例来源:origin: com.almende.eve/eve-planning
/**
* Get todays events. A convenience method for easy testing
*
* @param calendarId
* @return
* @throws Exception
*/
public ArrayNode getEventsToday(@Optional @Name("calendarId") String calendarId)
throws Exception {
DateTime now = DateTime.now();
DateTime timeMin = now.minusMillis(now.getMillisOfDay());
DateTime timeMax = timeMin.plusDays(1);
return getEvents(timeMin.toString(), timeMax.toString(), calendarId);
}
代码示例来源:origin: nl.cloudfarming.client/calendar-api
public static DateTime endOfDay(LocalDate localDate) {
return localDate.plusDays(1).toDateTimeAtStartOfDay().minusMillis(1);
}
代码示例来源:origin: qcadoo/mes
private static DeviationsReportCriteria fromLocalDates(final LocalDate fromDate, final Optional<LocalDate> maybeToDate) {
DateTime rangeBegin = fromDate.toDateTimeAtStartOfDay();
DateTime rangeEnd = maybeToDate.or(LocalDate.now()).plusDays(1).toDateTimeAtStartOfDay().minusMillis(1);
Preconditions.checkArgument(rangeBegin.isBefore(rangeEnd), "Passed dates have wrong order.");
Interval searchInterval = new Interval(rangeBegin, rangeEnd);
return new DeviationsReportCriteria(searchInterval);
}
代码示例来源:origin: org.marketcetera/core
/**
* Populate the MDEntry given group with the given date time value.
*
* @param inGroup a <code>Group</code> value
* @param inDateTime a <code>DateTime</code> value
*/
public void populateMdEntryGroupWithDateTime(Group inGroup,
DateTime inDateTime)
{
if(inDateTime == null) {
return;
}
// TODO the time doesn't seem quite right
inGroup.setField(new quickfix.field.MDEntryDate(inDateTime.minusMillis(inDateTime.getMillisOfDay()).toDate()));
inGroup.setField(new quickfix.field.MDEntryTime(inDateTime.minusYears(inDateTime.getYear()).minusDays(inDateTime.getDayOfYear()).toDate()));
}
/**
代码示例来源:origin: com.almende.eve/eve-planning
/**
* Get the timestamp rounded to the next half hour
* @return
*/
private DateTime getNextHalfHour() {
DateTime next = DateTime.now();
next = next.minusMillis(next.getMillisOfSecond());
next = next.minusSeconds(next.getSecondOfMinute());
if (next.getMinuteOfHour() > 30) {
next = next.minusMinutes(next.getMinuteOfHour());
next = next.plusMinutes(60);
} else {
next = next.minusMinutes(next.getMinuteOfHour());
next = next.plusMinutes(30);
}
return next;
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-kinesis
@Test
public void testComparisonWithTimestamp() {
DateTime referenceTimestamp = DateTime.now();
assertThat(
checkpoint(AT_TIMESTAMP, referenceTimestamp.toInstant())
.isBeforeOrAt(recordWith(referenceTimestamp.minusMillis(10).toInstant())))
.isFalse();
assertThat(
checkpoint(AT_TIMESTAMP, referenceTimestamp.toInstant())
.isBeforeOrAt(recordWith(referenceTimestamp.toInstant())))
.isTrue();
assertThat(
checkpoint(AT_TIMESTAMP, referenceTimestamp.toInstant())
.isBeforeOrAt(recordWith(referenceTimestamp.plusMillis(10).toInstant())))
.isTrue();
}
内容来源于网络,如有侵权,请联系作者删除!