How to format day in Java

1 Answer

0 votes
package javaapplication1;

import java.text.SimpleDateFormat;
import java.util.Date;

public class JavaApplication1 {

    public static void main(String[] args) {

        Date date = new Date();

        SimpleDateFormat sdf = new SimpleDateFormat("d");
        System.out.println("d format: " + sdf.format(date));

        sdf = new SimpleDateFormat("dd");
        System.out.println("dd format: " + sdf.format(date));
    }
}
   
/*
   
run:
   
d format: 30
dd format: 30
   
*/

 



answered Oct 30, 2016 by avibootz

Related questions

1 answer 199 views
2 answers 248 views
248 views asked Oct 30, 2016 by avibootz
1 answer 136 views
1 answer 177 views
1 answer 186 views
...