LoginSignup
8

More than 5 years have passed since last update.

16 進数文字列の変換

Posted at

Integer から 16 進数文字列へ。

Integer num = 10079283;
String hex = String.format("0x%06x", Integer.valueOf(num));
// 0x99cc33

16 進数文字列から Integer へ。

String str = "0x99cc33";
Integer num = Integer.decode(str);
// 10079283

参考
http://stackoverflow.com/questions/5446863/pad-digits-until-string-is-8-chars-long-in-java

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8