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

x33g5p2x  于2022-01-23 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(254)

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

LocalTime.plusHours介绍

[英]Returns a copy of this time plus the specified number of hours.

This LocalTime instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

LocalTime added = dt.plusHours(6); 
LocalTime added = dt.plus(Period.hours(6)); 
LocalTime added = dt.withFieldAdded(DurationFieldType.hours(), 6);

[中]返回此时间加上指定小时数的副本。
此LocalTime实例是不可变的,不受此方法调用的影响。
以下三行实际上是相同的:

LocalTime added = dt.plusHours(6); 
LocalTime added = dt.plus(Period.hours(6)); 
LocalTime added = dt.withFieldAdded(DurationFieldType.hours(), 6);

代码示例

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

assertEquals("3 days ago", DateUtils.getRelativeTimeSpanString(ctx, LocalDate.now().minusDays(3)));
assertEquals("in 1 hour", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().plusHours(1)));
assertEquals("in 3 hours", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().plusHours(3)));
assertEquals("1 hour ago", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().minusHours(1)));
assertEquals("3 hours ago", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().minusHours(3)));

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

LocalTime twoHoursLater = dt.minusMinutes(10);
 twoHoursLater = twoHoursLater.plusHours(2);

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

LocalTime time = LocalTime.now(); 
LocalTime newTime = time.plusHours(12);

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

int hours = (parsed from input);
DateTimeFormatter dtf = DateTimeFormat.forPattern("HH:mm");     
LocalTime startTime = dtf.parseLocalTime(stringWithTimeFromUser);
LocalTime endTime = startTime.plusHours(hours);

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

static final DateTimeFormatter AM_PARSER = DateTimeFormat.forPattern("hh:mm:ss 'am'");
static final DateTimeFormatter PM_PARSER = DateTimeFormat.forPattern("hh:mm:ss 'pm'");

public static LocalTime parseServer(String input) {
 if (input.endsWith("am")) {
  return AM_PARSER.parseLocalTime(input);
 } else {
  LocalTime lt = PM_PARSER.parseLocalTime(input);
  return lt.plusHours(12); // necessary because we parse pm only as literal
 }
}

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

LocalTime timeInAM=new LocalTime(hourOfDay, minuteOfHour);
LocalTime timeOutAM=new LocalTime(hourOfDay, minuteOfHour);
LocalTime timeInPM=new LocalTime(hourOfDay, minuteOfHour);
LocalTime timeOutPM=new LocalTime(hourOfDay, minuteOfHour);

LocalTime amInterval = timeOutAM.minusHours(timeInAM.getHourOfDay()).minusMinutes(timeInAM.getMinuteOfHour());
LocalTime pmInterval = timeOutPM.minusHours(timeInPM.getHourOfDay()).minusMinutes(timeInPM.getMinuteOfHour());

LocalTime total = pmInterval.plusHours(amInterval.getHourOfDay()).plusMinutes(amInterval.getMinuteOfHour());

代码示例来源:origin: com.querydsl/querydsl-jpa

@Test
@NoEclipseLink
@NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653
public void case1_time() {
  List<LocalTime> rv = query().from(cat).select(cat.name.when("Bob").then(new LocalTime())
      .otherwise(new LocalTime().plusHours(1))).fetch();
  assertInstancesOf(LocalTime.class, rv);
}

相关文章