Java tutorial
import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { public static void main(String[] args) { int areaCode = 123; int exchangeCode = 456; NumberFormat nf3 = new DecimalFormat("0000"); System.out.println(nf3.format(areaCode) + "-" + nf3.format(exchangeCode)); } }