EN · DE · RU · FR · ES

#1880: DateFormatType.java

projectforge-common/src/main/java/org/projectforge/common/DateFormatType.java Java enum — org.projectforge.common package, projectforge-common/src/main/java/org/projectforge/common/DateFormatType.java 99 lines · 20 code · 76 comments · 3 blank
Enumeration of date/time format presets used throughout ProjectForge's UI and export layers. Defines 16 distinct format levels from simple date-only (DATE_WITHOUT_YEAR) to full ISO 8601 timestamps (ISO_TIMESTAMP_MILLIS). Serves as a declarative format catalog — actual format pattern strings are resolved at runtime by DateHelper or the user's locale settings, enabling locale-aware date formatting without hardcoded pattern strings.

Architecture

Format Categories

Date-Only Formats

Enum ConstantExample PatternUse Case
DATE_WITHOUT_YEARdd.MM. / MM/dd / dd/MMBirthdays displayed without year, day-month lists
DATEdd.MM.yyyy / MM/dd/yyyyGeneral date display, form date fields
DATE_WITH_DAY_NAMEE, dd.MM.yyyyCalendar views, scheduling pages showing day of week
DATE_SHORTdd.MM.yy / MM/dd/yyExcel exports, compact list views
ISO_DATEyyyy-MM-ddDatabase queries, API responses, data interchange

Date-Time Formats

Enum ConstantPrecisionUse Case
DATE_TIME_SHORT_SECONDSDATE_SHORT + HH:mm:ssCompact logs, audit trail entries
DATE_TIME_SHORT_MINUTESDATE_SHORT + HH:mmCalendar event times, meeting schedules
DATE_TIME_MILLISDATE + HH:mm:ss.SSSPrecise timestamps with milliseconds
DATE_TIME_SECONDSDATE + HH:mm:ssGeneral timestamp display, audit logs
DATE_TIME_MINUTESDATE + HH:mmTimesheet entries, project time tracking

Time-Only Formats

Enum ConstantPatternUse Case
TIME_OF_DAY_SECONDSHH:mm:ssDuration displays, stopwatch-style views
TIME_OF_DAY_MINUTESHH:mmTime inputs, meeting times, opening hours

ISO 8601 Timestamp Formats

Enum ConstantPatternUse Case
ISO_TIMESTAMP_MILLISyyyy-MM-dd HH:mm:ss.SSSHigh-precision logging, database audit columns
ISO_TIMESTAMP_SECONDSyyyy-MM-dd HH:mm:ssAPI responses, JSON serialization, REST endpoints
ISO_TIMESTAMP_MINUTESyyyy-MM-dd HH:mmCalendar export (iCal), scheduling systems

Special Format

Enum ConstantPatternUse Case
DAY_OF_WEEK_SHORTEE (Mon, Tue, ...)Week headers in calendar views, timesheet week overview

Locale Awareness

The Javadoc comments for DATE and DATE_WITHOUT_YEAR show multiple pattern examples ("dd.MM.", "MM/dd", "dd/MM"), indicating these enum constants represent format intent rather than fixed patterns. The actual pattern string is resolved by DateHelper based on the user's locale:

This is a critical design feature for ProjectForge's international user base.

Excel Export Notation

The DATE_SHORT constant's Javadoc includes Excel-specific notation: "DD.MM.YY", "MM/DD/YY", "DD/MM/YY". This suggests the DateFormatType constants are also used by the Excel export module (org.projectforge.business.excel) which maps these enum values to Excel cell format strings — different from Java's SimpleDateFormat patterns (month is MM in Excel vs MM in Java, but uppercase differences exist).

Relationship with DateHelper

While this file only defines the enum constants, the actual format resolution logic resides in DateHelper (in the same package). DateHelper likely contains a getFormat(DateFormatType, Locale) or similar method that maps each enum constant to a locale-specific DateFormat or SimpleDateFormat instance.

Design Pattern: Enum as Declarative Catalog

This enum follows a pattern where the enum serves as a declarative catalog of available options, while the actual behavior is implemented elsewhere (DateHelper). This separation allows:

The ISO timestamp formats use a space separator (yyyy-MM-dd HH:mm:ss) rather than the ISO 8601 standard T separator (yyyy-MM-ddTHH:mm:ss). While common in database and display contexts, this is technically not strict ISO 8601. The format names suggest ISO compliance but the actual patterns are "ISO-like."
The 16 format constants cover a comprehensive range from "no year" to "millisecond precision." This granularity reflects ProjectForge's diverse use cases: timesheet management (minutes precision), financial reports (day precision), audit trails (millisecond precision), calendar views (day-of-week), and database migration tracking (ISO timestamps). Each format serves a specific UX or data requirement.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
7c79f1922 Copyright of source header -> 2020.
dd5ca38ac CopyRight of all java file-header updated or created.