java.time.LocalTime.plusMinutes()方法的使用及代码示例

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

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

LocalTime.plusMinutes介绍

[英]Returns a copy of this LocalTime with the specified period in minutes added.

This adds the specified number of minutes to this time, returning a new time. The calculation wraps around midnight.

This instance is immutable and unaffected by this method call.
[中]返回此LocalTime的副本,并添加指定的时间段(以分钟为单位)。
这会将指定的分钟数添加到此时间,并返回一个新时间。计算时间大约在午夜。
此实例是不可变的,不受此方法调用的影响。

代码示例

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

import org.joda.time.*;
import org.joda.time.format.*;

public class Test {
  public static void main(String[] args) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
    LocalTime time = formatter.parseLocalTime("14:10");
    time = time.plusMinutes(10);
    System.out.println(formatter.print(time));
  }       
}

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

LocalTime baseTime = LocalTime.of(((int)myNumber/100),myNumber%100);
while(...){
  LocalTime myTime=baseTime.plusMinutes(15);
}

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns a copy of this {@code LocalTime} with the specified period in minutes subtracted.
 * <p>
 * This subtracts the specified number of minutes from this time, returning a new time.
 * The calculation wraps around midnight.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param minutesToSubtract  the minutes to subtract, may be negative
 * @return a {@code LocalTime} based on this time with the minutes subtracted, not null
 */
public LocalTime minusMinutes(long minutesToSubtract) {
  return plusMinutes(-(minutesToSubtract % MINUTES_PER_DAY));
}

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

DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm");
 LocalTime lt = LocalTime.parse("14:10");
 System.out.println(df.format(lt.plusMinutes(10)));

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

public static LocalTime roundToQuarterHour(LocalTime time) {
 int oldMinute = time.getMinuteOfHour();
 int newMinute = 15 * (int) Math.round(oldMinute / 15.0);
 return time.plusMinutes(newMinute - oldMinute);
}

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

DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendPattern("hh:mm a").toFormatter();
LocalTime start = LocalTime.of(9, 0);
LocalTime end = start.plusMinutes(45);

System.out.println(dtf.format(start) + " to " + dtf.format(end));

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

Map<Integer, String> timeInterval(int perDay)
{
  int minutes = 1440/perDay ;
  Map<Integer, String> timeInt = new HashMap<Integer, String>() ;
  LocalTime time =  DateTimeFormat.forPattern("HH:mm").parseLocalTime("09:00");

  for(int i=0; i < perDay; i++) {
    timeInt.put(i,time.toString());
    time = time.plusMinutes(minutes);
  }

  return timeInt;
}

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns a copy of this {@code OffsetTime} with the specified period in minutes added.
 * <p>
 * This adds the specified number of minutes to this time, returning a new time.
 * The calculation wraps around midnight.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param minutes  the minutes to add, may be negative
 * @return an {@code OffsetTime} based on this time with the minutes added, not null
 */
public OffsetTime plusMinutes(long minutes) {
  return with(time.plusMinutes(minutes), offset);
}

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

for(LocalTime time = startTime; time.isBefore(endTime)  ; time = time.plusMinutes(15) ){
            //operations
 }

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

LocalTime start = new LocalTime(13, 45);
LocalTime later = start.plusMinutes(35);

代码示例来源:origin: xiangwbs/springboot

/**
 * 获取n分钟前/后时间字符串
 * 返回格式:HH:mm/HH:mm:ss
 *
 * @param time   格式:HH:mm/HH:mm:ss
 * @param minute 分钟
 * @return
 */
public static String timeAddMinusMinutes(String time, int minute) {
  LocalTime localTime = LocalTime.parse(time);
  LocalTime nowLocalTime = minute >= 0 ? localTime.plusMinutes(minute) : localTime.minusMinutes(Math.abs(minute));
  return nowLocalTime.toString();
}

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

java.sql.Time myTime = java.sql.Time.valueOf("15:33:00");
LocalTime localtime = myTime.toLocalTime();
localtime = localtime.plusMinutes(30);
String output = localtime.toString();

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

StringBuilder enums = new StringBuilder ();
LocalTime start = LocalTime.MIN;
for ( int i = 0 ; i < ( 24 * 4 ) ; i ++ ) {
  if ( enums.length () > 0 ) {
    enums.append ( " , " );
  }
  LocalTime stop = start.plusMinutes ( 15 );
  String name = "T_" + start.toString () + "_" + stop.toString ();
  name = name.replaceAll ( ":" , "" );
  enums.append ( name );
  // Setup next loop
  start = stop;
}
System.out.println ( "enums: " + enums );

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

DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendHourOfDay(2).appendLiteral(":").appendMinuteOfHour(2).appendLiteral(" ").appendHalfdayOfDayText().toFormatter();
LocalTime start = LocalTime.parse("09:00 am", dtf);
LocalTime end = start.plusMinutes(45);

System.out.println(start.toString("hh:mm a") + " to " + end.toString("hh:mm a"));

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

LocalTime start = new LocalTime(9, 0, 0);
LocalTime stop = new LocalTime(17, 0, 0);
LocalTime time = start;     // Just use the reference

while (time.compareTo(stop) <= 0)
{
  method(time, start, stop);
  time = time.plusMinutes(1);
}

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

LocalTime start = new LocalTime(13, 46);
LocalTime end = new LocalTime(18, 46);
LocalTime current = start;

for (int i = 0; current.isBefore(end); i++) {
  // code your print action here
  current = current.plusMinutes((i < 2) ? 30 : 60);
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

public void zInternalTryChangeTimeByIncrement(int changeAmountMinutes) {
  LocalTime timeToTry = getTime().plusMinutes(changeAmountMinutes);
  if (!InternalUtilities.isTimeVetoed(settings.getVetoPolicy(), timeToTry)) {
    setTime(timeToTry);
  }
}

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

LocalTime time = new LocalTime(8, 0); // corresponds to 08:00
LocalTime laterBy8Minutes = time.plusMinutes(7);
LocalTime earlierBy8Minutes = time.minusMinutes(7);
String sLaterBy8Minutes = laterBy8Minutes.toString("HH:mm"); // 08:07
String sEarlierBy8Minutes = earlierBy8Minutes.toString("HH:mm"); // 07:53

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * mouseReleased, This will be called when the spinner button is pressed down. This is
 * only called once before release no matter how long the mouse button is held down.
 */
@Override
public void mousePressed(MouseEvent event) {
  if (!isEnabled()) {
    return;
  }
  if (getTime() == null) {
    setTime(LocalTime.NOON);
  }
  if (event.getSource() == getComponentDecreaseSpinnerButton()) {
    setTime(getTime().plusMinutes(-1));
    decreaseTimer.start();
  } else {
    setTime(getTime().plusMinutes(1));
    increaseTimer.start();
  }
}

代码示例来源:origin: com.healthmarketscience.jackcess/jackcess

@Override
 protected Value eval3(EvalContext ctx, Value param1, Value param2, Value param3) {
  int hours = param1.getAsLongInt(ctx);
  int minutes = param2.getAsLongInt(ctx);
  int seconds = param3.getAsLongInt(ctx);
  // we have to construct incrementatlly to handle out of range values
  LocalTime lt = ColumnImpl.BASE_LT.plusHours(hours).plusMinutes(minutes)
   .plusSeconds(seconds);
  return ValueSupport.toValue(lt);
 }
});

相关文章