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