All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.meta.FormattingDocumentation Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.meta;

import org.javamoney.moneta.format.CurrencyStyle;

import java.time.format.DateTimeFormatter;

/**
 *
 * 

Temporal Data

* *

* *

Do not use {@link java.text.SimpleDateFormat}, it does not work with all temporal data types of the SDK:

* * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#doNotUseSimpleDateFormat()} * * Use {@link java.time.LocalDate#format(DateTimeFormatter)} with {@link DateTimeFormatter} instead: * * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatLocalDate()} * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatLocalTime()} * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatZonedDateTime()} * * *

Monetary Data

* * The SDK has a dependency to Moneta, the reference implementation for JSR 354 - Currency and Money. * We suggest to read the Moneta Userguide. * *

Creating MonetaryAmount values

* * The following example shows different ways to create the same money representation: * * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#createMoney()} * *

Formatting MonetaryAmount values

* *

For formatting you can just get a formatter per locale.

*

Example for Germany:

* * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatMoneyByGermanLocale()} * *

Example for the USA:

* * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatMoneyByUsLocale()} * *

You can also use the locale and force to use the currency symbol instead of the currency code:

* {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatMoneyCustom()} * *

If that is not flexible enough you can specify a pattern:

* * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#formatMoneyCustom3()} * *

¤ is the currency sign which can be formatted with the styles {@link CurrencyStyle#CODE}, {@link CurrencyStyle#NAME}, {@link CurrencyStyle#NUMERIC_CODE} and {@link CurrencyStyle#SYMBOL}.

* *

Sorting MonetaryAmount values

* *

By the amount:

* {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#moneySortByAmount()} * *

By the currency and the amount:

* * {@include.example io.sphere.sdk.meta.FormattingDocumentationTest#moneySortByCurrencyAndAmount()} * * * * */ public class FormattingDocumentation { private FormattingDocumentation() { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy