-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClock.java
35 lines (30 loc) · 835 Bytes
/
Clock.java
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
29
30
31
32
33
34
35
/*
* object to hold basic clock and calaendar functions.
*/
package natasha;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import static natasha.Natasha.println;
/**
*
* @author garyanewsome
*/
public class Clock {
public static void getTime() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a");
println(sdf.format(cal.getTime()));
}
public static void getDate() {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = new Date();
println(dateFormat.format(date));
}
public static String getUpdateDate() {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = new Date();
return (dateFormat.format(date));
}
}