0

I want to change to value of the major and minor of my beacon by calling a shell script from a java code. If for example I want to set the value of the Major to 39321, I have to pass a string with the value 99 99 as parameter to the shell code. If I want to set it to 34866, I have to pass the hex code 88 32. How can I convert from a long number like the 39321 to this two character composed hex number like 99 99?

Celiiine
  • 19
  • 5

1 Answers1

0

You can use toHexString(long i) method from Long class.

For example :

Long.toHexString(39321)

It returns a string representation of the long argument as an unsigned integer in base 16.

Necromancer
  • 869
  • 2
  • 9
  • 25
  • This will return 0000000000000000000000000000003339333231, I am expecting to have 99 99 as result. – Celiiine Jun 10 '16 at 09:52
  • @Celiiine I got String result **9999** when testing with my eclipse. I am using **jdk1.8.0_72** and running on window 8. – Necromancer Jun 10 '16 at 10:02