8326627: Document Double/Float.valueOf(String) behavior for numeric strings with non-ASCII digits

Reviewed-by: iris, jlu
This commit is contained in:
Naoto Sato 2024-03-29 17:55:57 +00:00
parent 5b05f8e0c4
commit 8a0ef811ed
4 changed files with 25 additions and 11 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2024, 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
@ -815,10 +815,6 @@ public final class Double extends Number
* Finally, after rounding a {@code Double} object representing
* this {@code double} value is returned.
*
* <p> To interpret localized string representations of a
* floating-point value, use subclasses of {@link
* java.text.NumberFormat}.
*
* <p>Note that trailing format specifiers, specifiers that
* determine the type of a floating-point literal
* ({@code 1.0f} is a {@code float} value;
@ -889,6 +885,16 @@ public final class Double extends Number
* }
* }
*
* @apiNote To interpret localized string representations of a
* floating-point value, or string representations that have
* non-ASCII digits, use {@link java.text.NumberFormat}. For
* example,
* {@snippet lang="java" :
* NumberFormat.getInstance(l).parse(s).doubleValue();
* }
* where {@code l} is the desired locale, or
* {@link java.util.Locale#ROOT} if locale insensitive.
*
* @param s the string to be parsed.
* @return a {@code Double} object holding the value
* represented by the {@code String} argument.

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2024, 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
@ -489,10 +489,6 @@ public final class Float extends Number
* Finally, after rounding a {@code Float} object representing
* this {@code float} value is returned.
*
* <p>To interpret localized string representations of a
* floating-point value, use subclasses of {@link
* java.text.NumberFormat}.
*
* <p>Note that trailing format specifiers, specifiers that
* determine the type of a floating-point literal
* ({@code 1.0f} is a {@code float} value;
@ -516,6 +512,16 @@ public final class Float extends Number
* for {@link Double#valueOf Double.valueOf} lists a regular
* expression which can be used to screen the input.
*
* @apiNote To interpret localized string representations of a
* floating-point value, or string representations that have
* non-ASCII digits, use {@link java.text.NumberFormat}. For
* example,
* {@snippet lang="java" :
* NumberFormat.getInstance(l).parse(s).floatValue();
* }
* where {@code l} is the desired locale, or
* {@link java.util.Locale#ROOT} if locale insensitive.
*
* @param s the string to be parsed.
* @return a {@code Float} object holding the value
* represented by the {@code String} argument.