Handling Date, Time, Text, Numeric and Boolean Values
Text
String is immutable: every trim, substring, replace or concat returns a new object, so use StringBuilder (not thread-safe) or StringBuffer (synchronized) for concatenation inside loops. == compares references, equals compares content. Text blocks strip incidental whitespace based on the least-indented line and require a line break after the opening delimiter.
Date and time
java.time types are immutable, so plusDays/minusHours return new instances rather than mutating. LocalDate, LocalTime and LocalDateTime carry no zone; ZonedDateTime and OffsetDateTime do; Instant is a point on the UTC timeline. Period is date-based (years, months, days) and pairs with LocalDate; Duration is time-based (seconds, nanos) and pairs with LocalTime, LocalDateTime or Instant. Mixing them - Duration.between(localDate1, localDate2) - throws UnsupportedTemporalTypeException. DateTimeFormatter.ofPattern("dd/MM/yyyy") is immutable and thread-safe; MM is month, mm is minutes, yyyy is year-of-era.
Numbers and booleans
Watch integer division (5/2 == 2), remainder sign (-7 % 3 == -1), and compound assignment's implicit cast: b += 1 compiles for a byte, b = b + 1 does not. Autoboxing caches Integer values from -128 to 127, so == between two Integer objects is a classic trap; compare with equals or as primitives. Use BigDecimal for money - equals compares scale, compareTo does not. Java has no truthiness: if (1) and if (x = 1) never compile.
Worked rule: whenever a java.time call seems to "do nothing", check whether you ignored its return value.