Java #44: How to Print out the Year and Day of the Month in Java using the Calendar Function

————–Source Code Screenshot—————-

—————–Full Source Code——————-

//Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose: How to use the Calendar Function to Print out the Year, and day of the Month

package dagbacomputers;

/**
*
* @author Akin
*/

//imports
import java.util.*;

public class DagbaComputers {

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
//Creating the calendar instance
Calendar todaysDate = Calendar.getInstance();

//Printing out the year
System.out.printf(“The year is: ” + todaysDate.get(Calendar.YEAR) + “\n”);

//Printing out the day
System.out.printf(“The day of the month is: ” + todaysDate.get(Calendar.DAY_OF_MONTH) + “\n”);

}//End of Main
}//End of DagbaComputers Class

—————–End of Program———————-

——————–Output————————-

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: