【问题标题】:how to decode an hexacidemal values to decimal ones with springboot?如何使用弹簧靴将十六进制值解码为十进制值?
【发布时间】:2021-06-10 08:48:16
【问题描述】:

我不知道如何使用 springboot 将十六进制值解码为十进制值 是否有可以帮助我的默认功能或者我应该自己开发功能 谢谢你

【问题讨论】:

    标签: spring-boot hex decimal decode


    【解决方案1】:

    您只需要 JAVA API,

    从十六进制到十进制

    String hexNumber = ...
    int decimal = Integer.parseInt(hexNumber, 16);
    System.out.println("Hex value is " + decimal);
    

    从十进制到十六进制

    如果您有要在 int 变量中转换的值,那么您可以简单地调用:

    int i = ...
    String hex = Integer.toHexString(i);
    System.out.println("Hex value is " + hex);
    

    如果字符串中有十进制数,那么你首先调用Integer.parseInt(),但这次你不需要任何第二个参数——十进制是默认值:

    String string = ...
    int no = Integer.parseInt(string);
    String hex = Integer.toHexString(no);
    System.out.println("Hex value is " + hex);
    

    查看全文here

    【讨论】:

    • 答案使用变量。
    • 感谢@Philippe Simo
    猜你喜欢
    • 2021-06-23
    • 1970-01-01
    • 2014-02-05
    • 2018-07-26
    • 2020-11-15
    • 2017-04-24
    • 2023-01-16
    • 2021-03-26
    相关资源
    最近更新 更多