1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package gov.nasa.pds.tools.time;
17
18 import java.text.SimpleDateFormat;
19 import java.util.Calendar;
20 import java.util.Date;
21
22 /***
23 * Class that can get the date and time
24 *
25 * @author mcayanan
26 *
27 */
28 public class ToolsTime {
29
30 private Calendar calendar;
31
32 public ToolsTime() {
33 calendar = Calendar.getInstance();
34 }
35
36 /***
37 * Get the current Date and Time
38 *
39 * @param df How the date and time will be represented. Use
40 * the patterns and letters defined in Java's SimpleDateFormat class.
41 *
42 * @return the current date and time
43 */
44 public String getTime(SimpleDateFormat df) {
45 Date date = calendar.getTime();
46 return df.format(date);
47 }
48 }