package dates;

import java.util.Date;

public class CurrentDate {

     public static void main(String[] args) {

        Date date = new Date();

        System.out.println("The time in milliseconds is "+

            date.getTime());

        System.out.println("The date is "+date.toString());

    }

}

 

 

 

 

package dates;

import java.util.Date;

public class CurrentDate {

 

    public static void main(String[] args) {

        Long timeMs = System.currentTimeMillis();

        timeMs += 24*60*60*1000;

        Date date = new Date(timeMs);

        System.out.println("The date tomorrow is "+date.toString());

    }

}

 

 

 

 

 

package dates;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

import java.util.GregorianCalendar;

 

public class Formatting {

    public static void main(String[] args) {

        Calendar c = new GregorianCalendar(2014, 0, 26, 15, 34, 0);

        Date date = c.getTime();

        DateFormat df1 = new SimpleDateFormat("dd MMMM yyyy HH:mm:ss");

        System.out.println(df1.format(date));

           

        df1 = new SimpleDateFormat("yyyy-M-dd h:mm aa");

        System.out.println(df1.format(date));

           

        df1 = new SimpleDateFormat("MMM dd, yyyy");

        System.out.println(df1.format(date));

           

        df1 = new SimpleDateFormat("yyyy");

        System.out.println(df1.format(date));

           

        df1 = new SimpleDateFormat("MMMM yy");

        System.out.println(df1.format(date));

    }

}