8232860: Error formatting integer values with MessageFormat.format() using HOST provider

Reviewed-by: rriggs
This commit is contained in:
Naoto Sato 2019-11-12 14:05:18 -08:00
parent de54eb1513
commit 9803a8dcb2
6 changed files with 69 additions and 5 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@ package sun.util.locale.provider;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.DecimalFormat;
import java.util.spi.LocaleServiceProvider;
/**
@ -60,4 +61,19 @@ public class HostLocaleProviderAdapter extends AuxLocaleProviderAdapter {
}
return null;
}
/**
* Utility to make the decimal format specific to integer, called
* by the platform dependent adapter implementations.
*
* @param df A DecimalFormat object
* @return The same DecimalFormat object in the argument, modified
* to allow integer formatting/parsing only.
*/
static DecimalFormat makeIntegerFormatter(DecimalFormat df) {
df.setMaximumFractionDigits(0);
df.setDecimalSeparatorAlwaysShown(false);
df.setParseIntegerOnly(true);
return df;
}
}