Package org.springframework.format.annotation

# Annotation Interface DurationFormat

@Documented @Retention(RUNTIME) @Target({METHOD,FIELD,PARAMETER,ANNOTATION_TYPE}) public @interface DurationFormat
Declares that a field or method parameter should be formatted as a `Duration`, according to the specified `Style` and `Unit`.

Since:
  6.2
Author:
  Simon Baslé

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`DurationFormat.Style`
`Duration` format styles.
`static enum`
`DurationFormat.Unit`
`Duration` format unit, which mirrors a subset of `ChronoUnit` and allows conversion to and from a supported `ChronoUnit` as well as conversion from durations to longs.

## Optional Element Summary

Optional Elements
Modifier and Type
Optional Element
Description
`DurationFormat.Unit`
`defaultUnit`
The `DurationFormat.Unit` to fall back to in case the `Style` needs a unit for either parsing or printing, and none is explicitly provided in the input.
`DurationFormat.Style`
`style`
The `DurationFormat.Style` to use for parsing and printing a `Duration`.

## Element Details

### style

DurationFormat.Style style
The `DurationFormat.Style` to use for parsing and printing a `Duration`.

Defaults to the JDK style (`DurationFormat.Style.ISO8601`).

Default:
  ISO8601

### defaultUnit

DurationFormat.Unit defaultUnit
The `DurationFormat.Unit` to fall back to in case the `Style` needs a unit for either parsing or printing, and none is explicitly provided in the input.

Defaults to `DurationFormat.Unit.MILLIS` if unspecified.

Default:
  MILLIS