Java #42: How to Create a Date and Print its Contents in Java

——-Source Code Screenshot———–

——-Full Source Code——–
//Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose: Create a date and retrieve it’s contents

package dagbacomputers;

/**
*
* @author Akin
*/

//imports
import java.time.LocalDate;

public class DagbaComputers {

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
//Creating the date
LocalDate gameRelease = LocalDate.of(2017, 5, 18);

//Turing the day of the month into an integer
int day = gameRelease.getDayOfMonth();

//Day Test
System.out.printf(“Day of the month: ” + day + “\n”);

//Turning month into an integer
int month = gameRelease.getMonthValue();

//Month Test
System.out.printf(“Month of the year: ” + month + “\n”);

//Turing year into an integer
int year = gameRelease.getYear();

//Year Test
System.out.printf(“Year: ” + year + “\n”);

//Break
System.out.printf(“———-All together———–” + “\n”);

//Printing all the values out together
System.out.printf(“The Game Release Date: ” + month + “,” + day + “,” + year + “\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: