Java Code Examples for java.time.LocalDateTime#withSecond()
The following examples show how to use
java.time.LocalDateTime#withSecond() .
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
Source Project: dragonwell8_jdk File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 2
Source Project: arcusplatform File: Instants.java License: Apache License 2.0 | 5 votes |
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
Source Project: TencentKona-8 File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 4
Source Project: jdk8u60 File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 5
Source Project: openjdk-jdk8u File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 6
Source Project: openjdk-jdk8u-backup File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 7
Source Project: openjdk-jdk9 File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 8
Source Project: jdk8u-jdk File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 9
Source Project: hottub File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 10
Source Project: openjdk-8-source File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 11
Source Project: openjdk-8 File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 12
Source Project: jdk8u_jdk File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 13
Source Project: jdk8u-jdk File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 14
Source Project: jdk8u-dev-jdk File: TCKLocalDateTime.java License: GNU General Public License v2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 15
Source Project: axelor-open-suite File: ImportDateTime.java License: GNU Affero General Public License v3.0 | 5 votes |
public LocalDateTime updateSecond(LocalDateTime datetime, String second) { if (!Strings.isNullOrEmpty(second)) { Matcher matcher = patternMonth.matcher(second); if (matcher.find()) { Long seconds = Long.parseLong(matcher.group()); if (second.startsWith("+")) datetime = datetime.plusSeconds(seconds); else if (second.startsWith("-")) datetime = datetime.minusSeconds(seconds); else datetime = datetime.withSecond(seconds.intValue()); } } return datetime; }
Example 16
Source Project: j2objc File: TCKLocalDateTime.java License: Apache License 2.0 | 5 votes |
@Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { t = t.withSecond(i); assertEquals(t.getSecond(), i); } }
Example 17
Source Project: MeteoInfo File: TimeAxis.java License: GNU Lesser General Public License v3.0 | 4 votes |
/** * Update time tick values */ private void updateTimeTickValues() { LocalDateTime sdate = JDateUtil.fromOADate(this.getMinValue()); LocalDateTime edate = JDateUtil.fromOADate(this.getMaxValue()); LocalDateTime ssdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), sdate.getDayOfMonth(), sdate.getHour(), sdate.getMinute(), sdate.getSecond()); List<LocalDateTime> dates = new ArrayList<>(); switch (this.timeUnit) { case YEAR: sdate = LocalDateTime.of(sdate.getYear(), 1, 1, 0, 0, 0); if (!sdate.isBefore(ssdate)) { dates.add(sdate); } while (!sdate.isAfter(edate)) { sdate = sdate.withYear(sdate.getYear() + 1); dates.add(sdate); } break; case MONTH: sdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), 1, 0, 0, 0); if (!sdate.isBefore(ssdate)) { dates.add(sdate); } while (!sdate.isAfter(edate)) { sdate = sdate.plusMonths(1); if (!sdate.isBefore(ssdate)) { dates.add(sdate); } } break; case DAY: sdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), sdate.getDayOfMonth(), 0, 0, 0); if (!sdate.isBefore(ssdate)) { dates.add(sdate); } while (!sdate.isAfter(edate)) { sdate = sdate.plusDays(1); if (sdate.isBefore(edate)) { dates.add(sdate); } } break; case HOUR: sdate = LocalDateTime.of(sdate.getYear(), sdate.getMonthValue(), sdate.getDayOfMonth(), sdate.getHour(), 0, 0); if (!sdate.isBefore(ssdate)) { dates.add(sdate); } while (!sdate.isAfter(edate)) { sdate = sdate.plusHours(1); if (sdate.isBefore(edate)) { dates.add(sdate); } } break; case MINUTE: sdate = ssdate.withSecond(0); if (!sdate.isBefore(ssdate)) { dates.add(sdate); } while (!sdate.isAfter(edate)) { sdate = sdate.plusMinutes(1); if (sdate.isBefore(edate)) { dates.add(sdate); } } break; case SECOND: if (!sdate.isBefore(ssdate)) { dates.add(sdate); } while (!sdate.isAfter(edate)) { sdate = sdate.plusSeconds(1); if (sdate.isBefore(edate)) { dates.add(sdate); } } break; } double[] tvs = new double[dates.size()]; for (int i = 0; i < dates.size(); i++) { tvs[i] = JDateUtil.toOADate(dates.get(i)); } this.setTickValues(tvs); }
Example 18
Source Project: charts File: Axis.java License: Apache License 2.0 | 4 votes |
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; } }