MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.util.Calendar;

public class MainClass {

    public static void main(String[] args) {

        // get a calendar using the default time zone and locale.
        Calendar calendar = Calendar.getInstance();

        // set Date portion to January 1, 1970
        calendar.set(Calendar.YEAR, 1970);
        calendar.set(Calendar.MONTH, Calendar.JANUARY);
        calendar.set(Calendar.DATE, 1);

        // normalize the object
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime());
    }

}