forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDate.java
More file actions
28 lines (23 loc) · 772 Bytes
/
Copy pathDate.java
File metadata and controls
28 lines (23 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Date {
public static void main(String[] args) {
// initialize vars and assign values
String day, month;
int date, year;
day = "Tuesday";
date = 10;
month = "May";
year = 2016;
// print the date in standard American format
printAmerican(day, month, date, year);
//print the date in standard European format
printEuropean(day, date, month, year);
}
public static void printAmerican(String day, String month, int date, int year) {
System.out.println("American format:");
System.out.printf("%s, %s %d, %d\n", day, month, date, year);
}
public static void printEuropean(String day, int date, String month, int year) {
System.out.println("European format:");
System.out.printf("%s %d %s %d\n", day, date, month, year);
}
}