Java SimpleDateFormat format day as "1", "01"
import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] args) { Date date = new Date(); /*from w w w.ja v a 2 s . c o m*/ //formatting day in d format like 1,2 etc SimpleDateFormat sdf = new SimpleDateFormat("d"); System.out.println("Current day in d format : " + sdf.format(date)); //formatting day in dd format like 01, 02 etc. sdf = new SimpleDateFormat("dd"); System.out.println("Current day in dd format : " + sdf.format(date)); } }