Java Tutorial 120 lessons · 2:32:01+ of video
Java Home What Java Is, Where Java Is Used and How Java Runs Your Code
What Java Is Where Java Is Used How Java Runs Your Code Installing the JDK, Trying Java in JShell and Your First Program
Installing the JDK Trying Java in JShell Your First Program The main Method, println and print, and Comments
The main Method println and print Comments Variables, Primitive Types, int and long
Variables Primitive Types int and long double and float, Arithmetic, Division and Remainder
double and float Arithmetic Division and Remainder char and boolean, Type Casting, Practice: A Simple Calculator
char and boolean Type Casting Practice: A Simple Calculator Strings, Joining Strings and String Methods
Strings Joining Strings String Methods Comparing Strings, Escapes and Text Blocks, String.format
Comparing Strings Escapes and Text Blocks String.format Reading Input with Scanner, Reading Numbers, Practice: A Receipt
Reading Input with Scanner Reading Numbers Practice: A Receipt Comparison Operators, if, else and else if
Comparison Operators if else and else if Logical Operators, The Ternary Operator and switch
Logical Operators The Ternary Operator switch Switch Expressions, Nested Decisions, Practice: Grade Checker
Switch Expressions Nested Decisions Practice: Grade Checker while Loops, do while and for Loops
while Loops do while for Loops break and continue, Nested Loops and Loop Patterns
break and continue Nested Loops Loop Patterns Counting and Summing, Infinite Loops and Off-by-One, Practice: Times Table
Counting and Summing Infinite Loops and Off-by-One Practice: Times Table What an Array Is, Creating Arrays and Looping Over Arrays
What an Array Is Creating Arrays Looping Over Arrays The Enhanced for Loop, The Arrays Class and Searching an Array
The Enhanced for Loop The Arrays Class Searching an Array Two-Dimensional Arrays, Common Array Mistakes, Practice: Top Scores
Two-Dimensional Arrays Common Array Mistakes Practice: Top Scores Defining Methods, Parameters and Return Values
Defining Methods Parameters Return Values Overloading, Scope and Pass by Value
Overloading Scope Pass by Value Recursion, Varargs, Practice: Temperature Converter
Recursion Varargs Practice: Temperature Converter Classes and Objects, Fields and Constructors
Classes and Objects Fields Constructors The this Keyword, Instance Methods and static
The this Keyword Instance Methods static Access Modifiers, Getters and Setters, and toString
Access Modifiers Getters and Setters toString Encapsulation, Inheritance and super
Encapsulation Inheritance super Overriding, Polymorphism and Abstract Classes
Overriding Polymorphism Abstract Classes Interfaces, Records and Enums
Interfaces Records Enums ArrayList, Generics and Wrapper Classes
ArrayList Generics Wrapper Classes and Autoboxing HashMap, Looping Over a Map and HashSet
HashMap Looping Over a Map HashSet Sorting with Comparator, Removing While Looping, Practice: Word Counter
Sorting with Comparator Removing While Looping Practice: Word Counter What Exceptions Are, try and catch, and finally
What Exceptions Are try and catch finally Checked and Unchecked, throw and Custom Exceptions, try-with-resources
Checked and Unchecked throw and Custom Exceptions try-with-resources Writing Files, Reading Files, Practice: Save and Load
Writing Files Reading Files Practice: Save and Load Lambdas, Functional Interfaces and Method References
Lambdas Functional Interfaces Method References Streams, filter, map and collect, More Stream Operations
Streams filter, map and collect More Stream Operations Optional, var and Pattern Matching
Optional var Pattern Matching StringBuilder, Dates and Times, Packages and Imports
StringBuilder Dates and Times Packages and Imports Project: The Plan, The Task Record and The TaskList Class
Project: The Plan Project: The Task Record Project: The TaskList Class Project: Saving Tasks, Loading Tasks and Reports with Streams
Project: Saving Tasks Project: Loading Tasks Project: Reports with Streams Project: The Menu, Where to Go Next and Course Recap
Project: The Menu Where to Go Next Course Recap Java · Lesson 110 of 120
Dates and Times Java.time.
⏱ 2 min read ▶ Video at 2:20:29 🎓 Free
▶ starts at 2:20:29 Dates are tricky. Months have different lengths, there are leap years, and time zones. Java's java dot time package handles all of that for you.
Dates are tricky Leap years, time zones java.time handles it Local date dot of makes a date, the fourteenth of March, twenty twenty six. Plus days adds thirty days, and handles the month change for us. Get day of week gives the weekday. Chrono unit counts the days between two dates. Local time holds a time of day. A formatter shows a date the way we like. And parse reads a date from text. Run it. The due date is the thirteenth of April, a Monday. The meeting ends at quarter past ten. And Christmas is after the due date.
Main.java java Copy
import java.time. * ;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
public class Main {
public static void main ( String [] args ) {
LocalDate start = LocalDate. of ( 2026 , 3 , 14 );
LocalDate due = start. plusDays ( 30 );
System.out. println ( "Start " + start + ", due " + due);
System.out. println ( "Due on a " + due. getDayOfWeek ());
System.out. println ( "Days between: " + ChronoUnit.DAYS. between (start, due));
LocalTime meeting = LocalTime. of ( 9 , 30 ). plusMinutes ( 45 );
System.out. println ( "Meeting ends at " + meeting);
var fmt = DateTimeFormatter. ofPattern ( "d MMMM yyyy" );
System.out. println ( "Nicely: " + due. format (fmt));
LocalDate parsed = LocalDate. parse ( "2026-12-25" );
System.out. println ( "Christmas is after due? " + parsed. isAfter (due));
}
} Output
Start 2026-03-14, due 2026-04-13
Due on a MONDAY
Days between: 30
Meeting ends at 10:15
Nicely: 13 April 2026
Christmas is after due? true Each class holds a different kind of time. They're all immutable, so methods like plus days return a new value.
Class Holds Example LocalDate a date 2026-04-13 LocalTime a time of day 10:15 LocalDateTime both 2026-04-13T10:15 Duration / Period an amount of time PT45M, P30D
Prefer to watch? The full Java course is free All lessons in one video with animations, real code and chapters.
Watch free Java dot time has local date, local time, and more. They're immutable, and handle months, and leap years, correctly. Next, organising code into packages.
Key takeaways LocalDate.of plusDays DateTimeFormatter