This project implements a fundamental scheduling logic for time-sensitive applications. It compares two specific time objects—a morning meeting and an afternoon presentation—to verify their chronological sequence. By utilizing the modern Java Time API, the application ensures that the earlier event is correctly identified and displayed to the user.
- LocalTime Initialization: Sets
meetingat 08:00 andpresentationat 14:30. - Chronological Validation: Uses the
isBefore()method to compare twoLocalTimeinstances. - Dynamic Console Output: Prints a formatted string containing both time objects and their relation.
- Goal: Understand boolean logic in time comparisons.
- Java 8+ (java.time.LocalTime)
The application evaluates the expression meeting.isBefore(presentation). If true, it confirms that the meeting at 08:00 occurs before the presentation at 14:30. This approach is highly readable and avoids the common pitfalls of comparing raw hours and minutes as primitive integers.
Meeting at 08:00 is before presentation at 14:30
Project Structure:
src/com/yurii/pavlenko/
└── Solution.java
Code
package com.yurii.pavlenko;
import java.time.LocalTime;
public class Solution {
public static void main(String[] args) {
LocalTime meeting = LocalTime.of(8, 0);
LocalTime presentation = LocalTime.of(14, 30);
if (meeting.isBefore(presentation)) {
System.out.println("Meeting at " + meeting + " is before " + "presentation at " + presentation);
} else {
System.out.println("Presentation at " + presentation + " is before " + "meeting at " + meeting);
}
}
}This project is licensed under the MIT License.
Copyright (c) 2026 Yurii Pavlenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
License: MIT