List of usage examples for java.time LocalDate until
@Override
public Period until(ChronoLocalDate endDateExclusive)
From source file:Main.java
public static void main(String[] args) { LocalDate a = LocalDate.of(2014, 6, 30); Period p = a.until(LocalDate.of(2015, 6, 30)); System.out.println(p);//from w ww.ja v a2 s . c o m }
From source file:Main.java
public static void main(String[] argv) { LocalDate startEmployment = LocalDate.of(2010, Month.SEPTEMBER, 8); LocalDate today = LocalDate.now(); Period period = startEmployment.until(today); System.out.println("period = " + period); long numberOfDays = startEmployment.until(today, DAYS); System.out.println("numberOfDays = " + numberOfDays); }
From source file:Main.java
public static void main(String[] args) { LocalDate today = LocalDate.now(); // Temporal adjusters for adjusting the dates System.out.println("First date of this month= " + today.with(TemporalAdjusters.firstDayOfMonth())); LocalDate lastDayOfYear = today.with(TemporalAdjusters.lastDayOfYear()); System.out.println("Last date of this year= " + lastDayOfYear); Period period = today.until(lastDayOfYear); System.out.println("Period Format= " + period); System.out.println("Months remaining in the year= " + period.getMonths()); }
From source file:svc.managers.SMSManager.java
private String validateDOBString(String dob) { String errMsg = ""; dob = dob.trim();/* ww w.j a v a 2 s .c om*/ if (!dob.matches("^\\d{2}([./-])\\d{2}\\1\\d{4}$")) { //makes sure DOB is a valid date string format, also accepts "." and "-" errMsg = "You entered: '" + dob + "' Please re-enter your birthdate. The format is: MM/DD/YYYY"; } else { //be forgiving for dates delineated with "." or "-" dob = dob.replaceAll("[.-]", "/"); if (!DatabaseUtilities.isStringValidUSDateString(dob)) { //DOB is not a valid date, meaning month is out of bounds or day of month does not align with month or year errMsg = "The date you entered: '" + dob + "' was not a valid date. Please re-enter your birthdate using MM/DD/YYYY"; } else { //Check that the DOB is > 18 years old LocalDate dobLD = DatabaseUtilities.convertUSStringDateToLD(dob); LocalDate nowLD = DatabaseUtilities.getCurrentDate(); Period age = dobLD.until(nowLD); if (age.getYears() < 18) { errMsg = "You must be at least 18 years old to use www.yourSTLcourts.com"; } } } return errMsg; }