• <small id='TJIEx'></small><noframes id='TJIEx'>

    <i id='TJIEx'><tr id='TJIEx'><dt id='TJIEx'><q id='TJIEx'><span id='TJIEx'><b id='TJIEx'><form id='TJIEx'><ins id='TJIEx'></ins><ul id='TJIEx'></ul><sub id='TJIEx'></sub></form><legend id='TJIEx'></legend><bdo id='TJIEx'><pre id='TJIEx'><center id='TJIEx'></center></pre></bdo></b><th id='TJIEx'></th></span></q></dt></tr></i><div id='TJIEx'><tfoot id='TJIEx'></tfoot><dl id='TJIEx'><fieldset id='TJIEx'></fieldset></dl></div>

        <bdo id='TJIEx'></bdo><ul id='TJIEx'></ul>
      <legend id='TJIEx'><style id='TJIEx'><dir id='TJIEx'><q id='TJIEx'></q></dir></style></legend>
      <tfoot id='TJIEx'></tfoot>

      1. 将 BigDecimal 转换为 Integer

        Converting BigDecimal to Integer(将 BigDecimal 转换为 Integer)
        • <legend id='SjCOl'><style id='SjCOl'><dir id='SjCOl'><q id='SjCOl'></q></dir></style></legend>

              <bdo id='SjCOl'></bdo><ul id='SjCOl'></ul>

                  <tfoot id='SjCOl'></tfoot>

                  <i id='SjCOl'><tr id='SjCOl'><dt id='SjCOl'><q id='SjCOl'><span id='SjCOl'><b id='SjCOl'><form id='SjCOl'><ins id='SjCOl'></ins><ul id='SjCOl'></ul><sub id='SjCOl'></sub></form><legend id='SjCOl'></legend><bdo id='SjCOl'><pre id='SjCOl'><center id='SjCOl'></center></pre></bdo></b><th id='SjCOl'></th></span></q></dt></tr></i><div id='SjCOl'><tfoot id='SjCOl'></tfoot><dl id='SjCOl'><fieldset id='SjCOl'></fieldset></dl></div>
                1. <small id='SjCOl'></small><noframes id='SjCOl'>

                    <tbody id='SjCOl'></tbody>
                2. 本文介绍了将 BigDecimal 转换为 Integer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 Hibernate 方法,它返回一个 BigDecimal.我有另一个 API 方法,我需要将该数字传递给它,但它接受 Integer 作为参数.我无法更改这两种方法的返回类型或变量类型.

                  I have Hibernate method which returns me a BigDecimal. I have another API method to which I need to pass that number but it accepts Integer as parameter. I cannot change return types or variable types of both methods.

                  现在如何将 BigDecimal 转换为 Integer 并将其传递给第二个方法?

                  Now how to convert the BigDecimal into Integer and pass it to second method?

                  有办法解决吗?

                  推荐答案

                  你会调用 myBigDecimal.intValueExact()(或只是 intValue()) 如果您丢失信息,它甚至会抛出异常.这会返回一个 int,但自动装箱会处理这个问题.

                  You would call myBigDecimal.intValueExact() (or just intValue()) and it will even throw an exception if you would lose information. That returns an int but autoboxing takes care of that.

                  这篇关于将 BigDecimal 转换为 Integer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)
                3. <small id='dAMt7'></small><noframes id='dAMt7'>

                    <tfoot id='dAMt7'></tfoot>
                      <bdo id='dAMt7'></bdo><ul id='dAMt7'></ul>

                          <tbody id='dAMt7'></tbody>
                          <legend id='dAMt7'><style id='dAMt7'><dir id='dAMt7'><q id='dAMt7'></q></dir></style></legend>
                          <i id='dAMt7'><tr id='dAMt7'><dt id='dAMt7'><q id='dAMt7'><span id='dAMt7'><b id='dAMt7'><form id='dAMt7'><ins id='dAMt7'></ins><ul id='dAMt7'></ul><sub id='dAMt7'></sub></form><legend id='dAMt7'></legend><bdo id='dAMt7'><pre id='dAMt7'><center id='dAMt7'></center></pre></bdo></b><th id='dAMt7'></th></span></q></dt></tr></i><div id='dAMt7'><tfoot id='dAMt7'></tfoot><dl id='dAMt7'><fieldset id='dAMt7'></fieldset></dl></div>