Get date using Calendar class

Complete source code below will show you, how to get date on local computer in java using Calendar class.

import java.util.Calendar;
import java.util.Locale;

public class GetDate
public static void main(String[]args)
//Get a calendar using the default time zone and locale.
Calendar currentComputerDate=Calendar.getInstance();

//Print date

/*Print month in text representation. For example January is first month.
*Month that will print is in long representation.
*Short representation for January is Jan
*You can try to change Calendar.LONG to Calendar.SHORT
*Local.ROOT is useful constant for the root locale.

//Print year

Related Posts Plugin for WordPress, Blogger...

I Also Can Create T-Shirt Logo For You