Skip to content

Commit 9501bff

Browse files
kilinkbclozel
authored andcommitted
Use HexFormat in CharacterEditor
Use HexFormat to perform conversion for unicode-prefixed Strings in CharacterEditor. Closes gh-34798 Signed-off-by: Patrick Strawderman <[email protected]>
1 parent 542eb6f commit 9501bff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharacterEditor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.beans.propertyeditors;
1818

1919
import java.beans.PropertyEditorSupport;
20+
import java.util.HexFormat;
2021

2122
import org.jspecify.annotations.Nullable;
2223

@@ -97,13 +98,12 @@ public String getAsText() {
9798
return (value != null ? value.toString() : "");
9899
}
99100

100-
101-
private boolean isUnicodeCharacterSequence(String sequence) {
101+
private static boolean isUnicodeCharacterSequence(String sequence) {
102102
return (sequence.startsWith(UNICODE_PREFIX) && sequence.length() == UNICODE_LENGTH);
103103
}
104104

105105
private void setAsUnicode(String text) {
106-
int code = Integer.parseInt(text.substring(UNICODE_PREFIX.length()), 16);
106+
int code = HexFormat.fromHexDigits(text, UNICODE_PREFIX.length(), text.length());
107107
setValue((char) code);
108108
}
109109

0 commit comments

Comments
 (0)