Java examples for java.lang:int Format
Write code to format a number using the default locale settings.
//package com.java2s; import java.text.DateFormat; import java.text.NumberFormat; import java.util.Date; public class Main { public static void main(String[] argv) { long num = 42; System.out.println(prettyPrint(num)); }/*from w ww . j ava 2 s. com*/ private static final NumberFormat _numFormat = NumberFormat .getNumberInstance(); /** * formats a number using the default locale settings. */ public static String prettyPrint(long num) { return _numFormat.format(num); } /** * formats a number using the default locale settings. */ public static String prettyPrint(Number num) { return _numFormat.format(num); } /** * formats a date using the default locale settings. */ public static String prettyPrint(Date date) { return DateFormat.getDateTimeInstance().format(date); } }