Java Code Examples for java.time.LocalDateTime#withMinute()

The following examples show how to use java.time.LocalDateTime#withMinute() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 2
Source Project: arcusplatform   File: Instants.java    License: Apache License 2.0 5 votes vote down vote up
private static LocalDateTime setTime(LocalDateTime ldt, String time) {
   String [] parts = time.split("\\:");
   ldt = ldt.withHour(Integer.parseInt(parts[0]));
   if(parts.length > 1) {
      ldt = ldt.withMinute(Integer.parseInt(parts[1]));
   }
   if(parts.length > 2) {
      ldt = ldt.withSecond(Integer.parseInt(parts[2]));
   }
   return ldt;
}
 
Example 3
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 4
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 5
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 6
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 7
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 8
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 9
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 10
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 11
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 12
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 13
Source Project: FX-AlgorithmTrading   File: TimerChecker.java    License: MIT License 5 votes vote down vote up
/**
 * Timerの時刻を設定します
 * @param baseDateTime
 */
public void resetTimer(LocalDateTime baseDateTime) {
    logger.info("Reset timer. baseDateTime = {}", baseDateTime);

    // 最初データ時刻を設定
    LocalDateTime lastDateTime1min = baseDateTime.withNano(0).withSecond(0);
    LocalDateTime lastDateTime5min = lastDateTime1min.withMinute(NumberUtility.previousNumberByBase(lastDateTime1min.getMinute(), 5));
    LocalDateTime lastDateTime15min = lastDateTime5min.withMinute(NumberUtility.previousNumberByBase(lastDateTime1min.getMinute(), 15));
    LocalDateTime lastDateTime1hour = lastDateTime15min.withMinute(0);
    LocalDateTime lastDateTime1day = culcurateNextDailyUpdate(baseDateTime.toLocalDate().minusDays(1));
    if (lastDateTime1day.isBefore(lastDateTime1hour)) {
        lastDateTime1day = culcurateNextDailyUpdate(lastDateTime1day.toLocalDate());
    }

    lastDateTimeMap.put(Period.MIN_1, lastDateTime1min);
    lastDateTimeMap.put(Period.MIN_5, lastDateTime5min);
    lastDateTimeMap.put(Period.MIN_15, lastDateTime15min);
    lastDateTimeMap.put(Period.HOUR_1, lastDateTime1hour);
    lastDateTimeMap.put(Period.DAILY, lastDateTime1day);

    // 次回の更新タイミングを設定
    LocalDateTime nextDateTime1min = lastDateTime1min.plusMinutes(1);
    LocalDateTime nextDateTime5min = lastDateTime5min.plusMinutes(5);
    LocalDateTime nextDateTime15min = lastDateTime15min.plusMinutes(15);
    LocalDateTime nextDateTime1hour = lastDateTime1hour.plusHours(1);
    LocalDateTime nextDateTime1day = culcurateNextDailyUpdate(lastDateTime1day.toLocalDate());

    nextDateTimeMap.put(Period.MIN_1, nextDateTime1min);
    nextDateTimeMap.put(Period.MIN_5, nextDateTime5min);
    nextDateTimeMap.put(Period.MIN_15, nextDateTime15min);
    nextDateTimeMap.put(Period.HOUR_1, nextDateTime1hour);
    nextDateTimeMap.put(Period.DAILY, nextDateTime1day);
}
 
Example 14
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 15
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 16
public LocalDateTime updateMinute(LocalDateTime datetime, String minute) {
  if (!Strings.isNullOrEmpty(minute)) {
    Matcher matcher = patternMonth.matcher(minute);
    if (matcher.find()) {
      Long minutes = Long.parseLong(matcher.group());
      if (minute.startsWith("+")) datetime = datetime.plusMinutes(minutes);
      else if (minute.startsWith("-")) datetime = datetime.minusMinutes(minutes);
      else datetime = datetime.withMinute(minutes.intValue());
    }
  }
  return datetime;
}
 
Example 17
Source Project: j2objc   File: TCKLocalDateTime.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_withMinute_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
    for (int i = 0; i < 60; i++) {
        t = t.withMinute(i);
        assertEquals(t.getMinute(), i);
    }
}
 
Example 18
Source Project: charts   File: Axis.java    License: Apache License 2.0 4 votes vote down vote up
private List<LocalDateTime> makeDatesEven(List<LocalDateTime> dates, LocalDateTime dateTime) {
    // If the dates contain more dates than just the lower and upper bounds, make the dates in between even.
    if (dates.size() > 2) {
        List<LocalDateTime> evenDates = new ArrayList<>();

        // For each interval, modify the date slightly by a few millis, to make sure they are different days.
        // This is because Axis stores each value and won't update the tick labels, if the value is already known.
        // This happens if you display days and then add a date many years in the future the tick label will still be displayed as day.
        for (int i = 0; i < dates.size(); i++) {
            dateTime = dates.get(i);
            switch (currentInterval.getInterval()) {
                case YEARS:
                    // If its not the first or last date (lower and upper bound), make the year begin with first month and let the months begin with first day.
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withMonth(1);
                        dateTime.withDayOfMonth(1);
                    }
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(6000000);
                    break;
                case MONTHS:
                    // If its not the first or last date (lower and upper bound), make the months begin with first day.
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withDayOfMonth(1);
                    }
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(5000000);
                    break;
                case WEEKS:
                    // Make weeks begin with first day of week?
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(4000000);
                    break;
                case DAYS:
                    dateTime.withHour(0);
                    dateTime.withMinute(0);
                    dateTime.withSecond(0);
                    dateTime.withNano(3000000);
                    break;
                case HOURS:
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withMinute(0);
                        dateTime.withSecond(0);
                    }
                    dateTime.withNano(2000000);
                    break;
                case MINUTES:
                    if (i != 0 && i != dates.size() - 1) {
                        dateTime.withSecond(0);
                    }
                    dateTime.withNano(1000000);
                    break;
                case SECONDS:
                    dateTime.withSecond(0);
                    break;

            }
            evenDates.add(dateTime);
        }

        return evenDates;
    } else {
        return dates;
    }
}