Close Menu
Şevket Ayaksız
    What's Hot

    Java Period and Duration: Define What “One Day Later” Means

    November 11, 2026

    Oracle LEFT JOIN Filters: Preserve the Rows Your Report Needs

    November 11, 2026

    Java Comparator Null Handling: Decide Where Missing Values Belong

    November 11, 2026
    • software
    • Gadgets
    Şevket AyaksızŞevket Ayaksız
    • Home
    • Technology

      Apple: iPhone 17 and Older Models Hit With Unexpected $100 Price Increase

      September 10, 2026

      Apple Watch Intelligence Could Be a Major Accessibility Breakthrough

      September 10, 2026

      Apple May Skip the Base iPhone 18 This Year

      September 10, 2026

      FCC changes robot vacuum rules, potentially affecting future models

      August 8, 2026

      Samsung’s new 2TB 990 SSD drops to its lowest price yet

      August 6, 2026
    • Adobe

      Photoshop Smart Filters: Keep Effects Adjustable Throughout an Edit

      November 11, 2026

      Illustrator Scaling: Keep Strokes and Effects in Proportion

      November 10, 2026

      Illustrator Global Swatches: Make Color Changes Follow Your Design

      November 8, 2026

      Adobe Acrobat Bookmarks: Give Long PDFs a Useful Navigation Structure

      November 7, 2026

      How to Keep a Photoshop Adjustment on the Right Layer

      November 6, 2026
    • Microsoft

      Excel Structured References: Write Formulas That Explain Their Data

      November 11, 2026

      Word Pagination: Keep a Heading with the Paragraph That Follows

      November 10, 2026

      PowerPoint Selection Pane: Find and Manage Objects Behind Other Objects

      November 10, 2026

      Excel Data Validation: Guide Entry and Check What Arrives Later

      November 8, 2026

      PowerPoint Speaker Notes: Prepare the Message Behind the Slides

      November 7, 2026
    • java

      Java Period and Duration: Define What “One Day Later” Means

      November 11, 2026

      Java Comparator Null Handling: Decide Where Missing Values Belong

      November 11, 2026

      Java String.split: Preserve Empty Fields When Their Position Matters

      November 10, 2026

      Java String Case Conversion: Choose the Locale Explicitly

      November 8, 2026

      Java Optional: Choose Between a Default Value and Deferred Work

      November 7, 2026
    • Oracle

      Oracle LEFT JOIN Filters: Preserve the Rows Your Report Needs

      November 11, 2026

      Oracle Running Totals: Choose ROWS or RANGE Before Trusting the Result

      November 10, 2026

      Oracle NULLIF: Handle a Zero Denominator Without Inventing a Result

      November 8, 2026

      Oracle WHERE and HAVING: Filter the Right Level of Your Report

      November 8, 2026

      Oracle ROW_NUMBER: Make “Latest Record” Queries Deterministic

      November 7, 2026
    Şevket Ayaksız
    Anasayfa » Java Period and Duration: Define What “One Day Later” Means
    java

    Java Period and Duration: Define What “One Day Later” Means

    By sevketayaksizNovember 11, 2026No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Java Period and Duration: Define What “One Day Later” Means
    Share
    Facebook Twitter LinkedIn Pinterest Email

    “One day later” sounds precise until software must implement it. A reminder scheduled for the same local time tomorrow follows a calendar rule. A process that must wait exactly 24 hours follows an elapsed-time rule.

    Java provides Period and Duration to represent these different meanings. Choosing between them begins with the requirement, especially when a date and time belongs to a region whose clock can change.

    Separate calendar amounts from elapsed time

    Period represents years, months, and days in the ISO calendar system. Duration represents a time-based amount using seconds and nanoseconds.

    The Java documentation explicitly distinguishes their behavior when added to a ZonedDateTime: a one-day duration adds exactly 24 hours, while a one-day period adds a conceptual calendar day and attempts to preserve the local time.

    These expressions therefore communicate different intentions:

    Period calendarDay = Period.ofDays(1);
    Duration elapsedDay = Duration.ofHours(24);

    The distinction may remain invisible on many dates. That makes it particularly easy for an incorrect assumption to survive ordinary testing.

    Write the business sentence before the code

    For a daily appointment reminder, the requirement might say, “Notify the user at 9:00 tomorrow in the selected time zone.”

    For a temporary processing window, it might say, “The window ends 24 hours after this instant.”

    The first sentence emphasizes a local clock and calendar date. The second emphasizes a measured interval. Neither should be translated into code until the team agrees on that meaning.

    A useful review question is what the user expects when the local clock moves forward or backward. If nobody can answer, the ambiguity belongs in the requirement rather than inside an implementation detail.

    Treat months as calendar units

    A calendar month does not have one fixed duration in hours. A subscription renewal rule based on a month therefore needs calendar reasoning and a policy for dates near the end of the month.

    Conversely, a retry delay or short-lived timeout is naturally expressed as elapsed time. Calling a fixed number of seconds a “month” in a variable name does not make it a calendar month.

    Java’s Duration API treats its day unit as exactly 86,400 seconds. That is useful for fixed time arithmetic, but it should not be mistaken for a guarantee about every local calendar day.

    Keep the selected type visible at the boundary where a schedule or deadline enters the system.

    Test dates that reveal the difference

    Include a normal date and dates around a clock transition in a region that observes one. Compare both the resulting local time and the elapsed interval.

    For calendar-month rules, include dates near the end of January and other months with different lengths. State the expected behavior before evaluating the library result.

    Also test the time zone explicitly. A local date-time without a zone cannot, by itself, identify a unique moment everywhere.

    Finally, give variables names that expose their meaning, such as retryDelay, renewalPeriod, or expiresAt. A clear model makes later changes easier: product teams can revise a calendar policy without accidentally changing an unrelated elapsed-time calculation.

    Sources

    • Oracle — Period API
    • Oracle — Duration API
    Views: 2
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    sevketayaksiz
    • Website

    Related Posts

    Java Comparator Null Handling: Decide Where Missing Values Belong

    November 11, 2026

    Java String.split: Preserve Empty Fields When Their Position Matters

    November 10, 2026

    Java String Case Conversion: Choose the Locale Explicitly

    November 8, 2026
    Add A Comment

    Comments are closed.

    Şevket Ayaksız
    Instagram
    • Home
    • Adobe
    • microsoft
    • java
    • Oracle
    • Contact
    © 2026 Theme Designed by Şevket Ayaksız.

    Type above and press Enter to search. Press Esc to cancel.