jump to navigation

How to get the current date in java March 14, 2009

Posted by leppastar in java tips.

import java.util.*;

public class Demo{
static String[] month = {“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”}

public static void main(String[] args){
Calendar currentDate = Calendar.getInstance();
String month_str = month[currentDate.get(Calendar.MONTH);
String day = currentDate.get(Calendar.DATE);
String year = currentDate.get(Calendar.YEAR);

System.out.println(month+” “+day+”, “+year);




No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: