Date and hour Öffentlich

Date and hour

Brenda Gabriela Senra da Silva
Kurs von Brenda Gabriela Senra da Silva, aktualisiert vor 3 Monate Beitragende

Beschreibung

How to use

Modulinformationen

Keine Merkmale angegeben
.of() .parse() .now()       plusDays, plusWeeks, plusMonths, plusYears minusDays, minusWeeks, minusMonths, minusYears isBefore, isAfter, isEqual Formatação de dados DateTimeFormatter ZonedDateTime  
Weniger sehen
Keine Merkmale angegeben
🧠 Super resumo mental Duration → small units (hours/minutes) Period → big units (years/months/days) ✅ Duration Duration measures time in: hours minutes seconds It is used with: LocalTime LocalDateTime 👉 Think of Duration as clock-based time. Example: Duration.between(start, end); It calculates how much time passed between two times.   ✅ Period Period measures time in: years months days It is used with: LocalDate 👉 Think of Period as calendar-based time. Example: Period.between(startDate, endDate); It calculates the difference in years, months, and days.
Weniger sehen
Keine Merkmale angegeben
 now(ZoneId) → quando quer hora de outro país now(ZoneId) → when you want the time of another country .now() Gets the current date or time from the system. .of() Creates a date/time by passing numbers. .parse() Converts a String into a date/time object   ✅ .now() → when you need the current moment You use it when the system needs to know: today’s date the current time the exact moment of a purchase whether something is overdue Real examples: LocalDate today = LocalDate.now(); LocalDateTime purchaseMoment = LocalDateTime.now();   📌 Commonly used in: payment systems due date verification logging systems   ✅ .of() → when you already know the values You use it when: you are creating a fixed date you are testing your code you are defining a specific rule LocalDate dueDate = LocalDate.of(2026, 5, 15);   📌 Commonly used in: unit tests system-defined dates calculated or predefined dates                                                                                         ✅ .parse() → when the date comes as TEXT You use it when: you receive a date from the user you receive a date from a database you receive a date from an API you read a date from a file   Example: LocalDate date = LocalDate.parse("2026-05-15"); 📌 Commonly used in: forms system integration JSON data processing
Weniger sehen
Keine Merkmale angegeben
✅ plusDays() Adds days to a date. LocalDate newDate = date.plusDays(10); 👉 Adds 10 days. ✅ plusWeeks() Adds weeks to a date. LocalDate newDate = date.plusWeeks(2); 👉 Adds 2 weeks (14 days). ✅ plusMonths() Adds months to a date. LocalDate newDate = date.plusMonths(3); 👉 Adds 3 months. ⚠ Important: If the day does not exist in the new month, Java adjusts automatically. Example: LocalDate.of(2026, 1, 31).plusMonths(1); Result → 2026-02-28 ✅ plusYears() Adds years to a date. LocalDate newDate = date.plusYears(1); 👉 Adds 1 year.
Weniger sehen
Keine Merkmale angegeben
LocalTime.parse(scanner.next(), formatter) → Para capturar o horário de entrada e saída no formato HH:mm. toHours() e toMinutesPart() → Para exibir a diferença de tempo em horas e minutos.  
Weniger sehen
Zusammenfassung anzeigen Zusammenfassung ausblenden