Java Data Type How to - Convert Java SQL Date from yyyy-MM-dd to dd MMMM yyyy format








Question

We would like to know how to convert Java SQL Date from yyyy-MM-dd to dd MMMM yyyy format.

Answer

/*from  w ww .j  a  v a  2s . co  m*/
import java.sql.Date;
import java.text.SimpleDateFormat;

public class Main {
    private static SimpleDateFormat df = new SimpleDateFormat("MMMM yyyy");

    public static void main(String[] args){

        Date oneDate = new Date(new java.util.Date().getTime());
        System.out.println(df.format(oneDate));
    }

}

The code above generates the following result.