Try OpenJDK 12 "Support for Compact Number Formatting (JDK-8177552)"

Overview

Try OpenJDK 12 Release Note "Support for Compact Number Formatting (JDK-8177552)".

Run

code

package com.mycompany.examplejdk12;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.text.NumberFormat;
import java.util.Locale;

public class ExampleMain {
    public static void main(String[] args) {
        Class<Locale> classLocale = Locale.class;
        for(Field field : classLocale.getDeclaredFields()) {
            //Find public static final Locale
            if((field.getModifiers() == (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL)) &&
               (field.getType() == classLocale)) {
                try {
                    var numberFormat = NumberFormat.getCompactNumberInstance((Locale)field.get(classLocale), NumberFormat.Style.SHORT);
                    System.out.println(field.getName() +  "[" + numberFormat.format(1000) + "]");
                }
                catch(IllegalAccessException e) {
                    System.out.println(e);
                }
            }
        }
    }
    
}

result

ENGLISH[1K]
FRENCH[1?k]
GERMAN[1.000]
ITALIAN[1.000]
JAPANESE[1,000]
KOREAN[1?]
CHINESE[1,000]
SIMPLIFIED_CHINESE[1,000]
TRADITIONAL_CHINESE[1,000]
FRANCE[1?k]
GERMANY[1.000]
ITALY[1.000]
JAPAN[1,000]
KOREA[1?]
CHINA[1,000]
PRC[1,000]
TAIWAN[1,000]
UK[1K]
US[1K]
CANADA[1K]
CANADA_FRENCH[1?000]
ROOT[1K]

memo

Recommended Posts

Try OpenJDK 12 "Support for Compact Number Formatting (JDK-8177552)"
Plans to support JDK 11 for Eclipse and Spring Boot