Guest User

Untitled

a guest
Aug 24th, 2019
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.redescreen.maquinas.lib;
  2.  
  3. import java.text.DecimalFormat;
  4.  
  5. public class FormatUtil {
  6.  
  7. public static String format(final double money) {
  8. if (money < 1000000.0) {
  9. return new DecimalFormat("#,###.#").format(money);
  10. }
  11. if (money < 1.0E9) {
  12. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1000000.0)) + "M";
  13. }
  14. if (money < 1.0E12) {
  15. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E9)) + "B";
  16. }
  17. if (money < 1.0E15) {
  18. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E12)) + "T";
  19. }
  20. if (money < 1.0E18) {
  21. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E15)) + "Q";
  22. }
  23. if (money < 1.0E21) {
  24. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E18)) + "QQ";
  25. }
  26. if (money < 1.0E24) {
  27. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E21)) + "S";
  28. }
  29. if (money < 1.0E27) {
  30. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E24)) + "SS";
  31. }
  32. if (money < 1.0E30) {
  33. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E27)) + "OC";
  34. }
  35. if (money < 1.0E33) {
  36. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E30)) + "N";
  37. }
  38. if (money < 1.0E36) {
  39. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E33)) + "D";
  40. }
  41. if (money < 1.0E39) {
  42. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E36)) + "UN";
  43. }
  44. if (money < 1.0E42) {
  45. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E39)) + "DD";
  46. }
  47. if (money < 1.0E45) {
  48. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E42)) + "TR";
  49. }
  50. if (money < 1.0E48) {
  51. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E45)) + "QT";
  52. }
  53. if (money < 1.0E51) {
  54. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E48)) + "QN";
  55. }
  56. if (money < 1.0E54) {
  57. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E51)) + "SD";
  58. }
  59. if (money < 1.0E57) {
  60. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E54)) + "SPD";
  61. }
  62. if (money < 1.0E60) {
  63. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E57)) + "OD";
  64. }
  65. if (money < 1.0E63) {
  66. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E60)) + "ND";
  67. }
  68. if (money < 1.0E66) {
  69. return String.valueOf(new DecimalFormat("#,###.#").format(money / 1.0E63)) + "VG";
  70. }
  71. return new DecimalFormat("#,###.#").format(money);
  72. }
  73. }
RAW Paste Data