Answers for "java check whether time is between two time"

1

java check two dates same day

public static boolean isSameDay(Date date1, Date date2) {
    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
    return fmt.format(date1).equals(fmt.format(date2));
}
Posted by: Guest on August-14-2021
12

java find time between two dates

public static String getAge(String birthdate) throws ParseException {
		LocalDate parsed = LocalDate.parse("1970-01-01");
		LocalDate current = LocalDate.now();
		
		Period p = Period.between(parsed, current);

  		// Returns time between date and now
		return p.getYears() + " Years, " + p.getMonths() + " Months, " + p.getDays() + " Days";
	}
Posted by: Guest on March-11-2021

Code answers related to "java check whether time is between two time"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language