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

wtf.metio.storageunits.model.FormatUtils Maven / Gradle / Ivy

/*
 * SPDX-FileCopyrightText: The Storage-Units Authors
 * SPDX-License-Identifier: 0BSD
 */
package wtf.metio.storageunits.model;

import org.jetbrains.annotations.NotNull;

import java.text.DecimalFormat;
import java.text.Format;
import java.text.NumberFormat;
import java.util.Locale;

final class FormatUtils {

    private FormatUtils() {
        // Hidden constructor.
    }

    static @NotNull Format asFormat(final @NotNull String pattern, final @NotNull Locale locale) {
        final var localizedFormat = NumberFormat.getNumberInstance(locale);
        final var outputFormat = (DecimalFormat) localizedFormat;
        outputFormat.applyPattern(pattern);
        return outputFormat;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy