long phoneNum = 123456789L; System.out.println(String.valueOf(phoneNum).replaceFirst("(d{3})(d{3})(d+)", "($1)-$2-$3"));