Class BrokenDownTime

java.lang.Object
io.github.connellite.util.internal.strftime.BrokenDownTime

public final class BrokenDownTime extends Object
The fields Strftime formats, held the way C holds them so that the arithmetic ported from glibc applies unchanged.

Two conventions come from struct tm rather than java.time: dayOfYear() counts from zero (tm_yday) and dayOfWeek() counts from Sunday (tm_wday). Every week-number formula in glibc is written against those, so converting them here keeps Strftime a transcription rather than a reinterpretation.

Unlike a real struct tm, the three fields a calendar does not hand over for free — the day of the year, the day of the week and the epoch second — are derived on first use, since a pattern such as "%Y-%m-%d" asks for none of them.

Instances are mutable and meant to be filled once per format call. year is proleptic, not the tm_year offset from 1900.

Based on glibc: __strftime_internal, which reads all of its input from a struct tm plus tm_gmtoff and the zone name.

  • Method Details

    • set

      public void set(ZonedDateTime value)
      Fills the fields from a zoned date-time, which already carries everything needed.
    • set

      public void set(Instant value, ZoneId zone)
      Fills the fields from an instant read in zone, without building a ZonedDateTime unless one is later asked for.
    • set

      public void set(OffsetDateTime value)
      Fills the fields from an offset date-time, keeping its own offset rather than moving it to another zone.
    • set

      public void set(Date value, ZoneId zone)
      Fills the fields from a legacy Date read in zone.
    • set

      public void set(Calendar value, ZoneId zone)
      Fills the fields from a Calendar instant read in zone.
    • set

      public void set(LocalDateTime value, ZoneId zone)
      Fills the fields from a wall-clock reading interpreted in zone. A reading that falls in a daylight-saving gap is moved forward by LocalDateTime.atZone(ZoneId), as elsewhere in this library.
    • set

      public void set(LocalDate value, ZoneId zone)
      Fills the fields from the start of value in zone.