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 192 views
2 answers 238 views
238 views asked Oct 30, 2016 by avibootz
1 answer 127 views
1 answer 169 views
1 answer 179 views
...