Skip to content

Commit 5b8d349

Browse files
author
Justin Lu
committed
4745837: Make grouping usage during parsing apparent in relevant NumberFormat methods
Reviewed-by: naoto
1 parent 4aa4b46 commit 5b8d349

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/java.base/share/classes/java/text/NumberFormat.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -883,21 +883,30 @@ public Object clone() {
883883
}
884884

885885
/**
886-
* Returns true if grouping is used in this format. For example, in the
887-
* English locale, with grouping on, the number 1234567 might be formatted
888-
* as "1,234,567". The grouping separator as well as the size of each group
889-
* is locale dependent and is determined by sub-classes of NumberFormat.
886+
* Returns true if grouping is used in this format. This applies to both
887+
* formatting and parsing. The grouping separator as well as the size of each
888+
* group is locale dependent and is determined by sub-classes of NumberFormat.
889+
* For example, consider a {@code NumberFormat} that expects a "{@code ,}"
890+
* grouping separator symbol with a grouping size of 3.
891+
* <ul>
892+
* <li> Formatting {@code 1234567} with grouping on returns {@code "1,234,567"}
893+
* <li> Parsing {@code "1,234,567"} with grouping off returns {@code 1}
894+
* <li> Parsing {@code "1,234,567"} with grouping off when {@link #isStrict()}
895+
* returns {@code true} throws {@code ParseException}
896+
* </ul>
890897
*
891898
* @return {@code true} if grouping is used;
892899
* {@code false} otherwise
893900
* @see #setGroupingUsed
901+
* @see ##leniency Leniency Section
894902
*/
895903
public boolean isGroupingUsed() {
896904
return groupingUsed;
897905
}
898906

899907
/**
900908
* Set whether or not grouping will be used in this format.
909+
* This applies to both formatting and parsing.
901910
*
902911
* @param newValue {@code true} if grouping is used;
903912
* {@code false} otherwise

0 commit comments

Comments
 (0)