mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
1bab38f2bf
commit
e78f65d842
@ -1573,14 +1573,14 @@ public class NumberUtil extends NumberValidator {
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
* @author dazer
|
* @author dazer
|
||||||
*/
|
*/
|
||||||
public static String intToRoman(int num) {
|
public static String intToRoman(final int num) {
|
||||||
if (num > 3999 || num < 1 ){
|
if (num > 3999 || num < 1 ){
|
||||||
return "";
|
return StrUtil.EMPTY;
|
||||||
}
|
}
|
||||||
String[] thousands = {"", "M", "MM", "MMM"};
|
final String[] thousands = {"", "M", "MM", "MMM"};
|
||||||
String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
|
final String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
|
||||||
String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
|
final String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
|
||||||
String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
|
final String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
|
||||||
|
|
||||||
return thousands[num / 1000] +
|
return thousands[num / 1000] +
|
||||||
hundreds[(num % 1000) / 100] +
|
hundreds[(num % 1000) / 100] +
|
||||||
@ -1596,13 +1596,13 @@ public class NumberUtil extends NumberValidator {
|
|||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
* @author dazer
|
* @author dazer
|
||||||
*/
|
*/
|
||||||
public static int romanToInt(String roman) {
|
public static int romanToInt(final String roman) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int prevValue = 0;
|
int prevValue = 0;
|
||||||
int currValue = 0;
|
int currValue;
|
||||||
|
|
||||||
for (int i = roman.length() - 1; i >= 0; i--) {
|
for (int i = roman.length() - 1; i >= 0; i--) {
|
||||||
char c = roman.charAt(i);
|
final char c = roman.charAt(i);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'I':
|
case 'I':
|
||||||
currValue = 1;
|
currValue = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user