List of usage examples for java.time Period ZERO
Period ZERO
To view the source code for java.time Period ZERO.
Click Source Link
From source file:Main.java
public static void main(String[] args) { Period p = Period.ZERO; System.out.println(p.toString()); }
From source file:Main.java
public static void main(String[] args) { Period p = Period.ofDays(12); System.out.println(p.equals(Period.ZERO)); }
From source file:org.edgexfoundry.scheduling.ScheduleContext.java
private void parsePeriodAndDuration(String frequency) { int periodStart = frequency.indexOf('P'); int timeStart = frequency.indexOf('T'); String freq = frequency;//from w w w. ja va 2s .c o m this.period = Period.ZERO; this.duration = Duration.ZERO; // Parse out the period (date) try { // If there is a duration 'T', remove it if (timeStart != -1) freq = frequency.substring(periodStart, timeStart); this.period = Period.parse(freq); } catch (IndexOutOfBoundsException | DateTimeParseException e) { logger.error("parsePeriodAndDuration() failed to parse period from '" + freq + "'"); } // Parse out the duration (time) try { // Make sure there is both a 'P' and 'T' if (periodStart != -1 && timeStart != -1) { freq = frequency.substring(timeStart, frequency.length()); this.duration = Duration.parse("P" + freq); } } catch (IndexOutOfBoundsException | DateTimeParseException e) { logger.error("parsePeriodAndDuration() failed to parse duration from 'P" + freq + "'"); } }