Micronaut features some built-in conversions that are useful, which are detailed below.

    Durations can be specified by appending the unit with a number. Supported units are , ms, m etc. The following table summarizes examples:

    For example to configure the default HTTP client read timeout:

    Using Duration Values

    Lists and arrays can be specified in Java properties files as comma-separated values or in YAML using native YAML lists. The generic types are used to convert the values. For example in YAML:

    Specifying lists or arrays in YAML

    1. my:
    2. integers:
    3. - 1
    4. - 2
    5. urls:
    6. - http://foo.com

    Or in Java properties file format:

    Specifying lists or arrays in Java properties comma-separated

    Alternatively you can use an index:

    Specifying lists or arrays in Java properties using index

    1. my.app.integers[1]=2

    For the above example configurations you can define properties to bind to with the target type supplied via generics:

    Using @ReadableBytes

    1. public void setMaxContentLength(@ReadableBytes int maxContentLength) {
    2. this.maxContentLength = maxContentLength;
    3. }

    With the above in place you can set micronaut.http.client.max-content-length using the following values:

    Table 2. @ReadableBytes Conversion
    Configuration ValueResulting Value

    10mb

    10 megabytes

    10kb

    10 kilobytes

    10gb

    10 gigabytes

    1024

    A raw byte length

    The annotation can be used on any setter to allow the date format to be specified when binding java.time date objects.

    Using for Dates