Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Comment formater les valeurs Hexadécimales


{filelink=6034}

import java.util.Date;
 
public class PrintfExamples {
  public static void main(String[] args) {
    //hex value is b5151397, B5151397
    System.out.printf("hex value is %1$h, %1$H", new Date() );
    //hex value
    System.out.printf("hex value is %1$h, %1$H", 0xCAFE );
    //hex value
    System.out.printf("hex value is %1$x, %1$X", 0xCAFE );
    System.out.printf("hex value is %1$#x, %1$#X", 0xCAFE );
  }
 
}
/*hex value is 5a341926, 5A341926
hex value is cafe, CAFE
hex value is cafe, CAFE
hex value is 0xcafe, 0XCAFE*/

A Voir sur le même Sujet:

  • valeurs hexadécimales en java
  • comment formater un hexadecimal
  • valeurs hexadecimales