View Javadoc

1   //Copyright 2006-2007, by the California Institute of 
2   //Technology. ALL RIGHTS RESERVED. United States Government 
3   //Sponsorship acknowledged. Any commercial use must be negotiated with 
4   //the Office of Technology Transfer at the California Institute of 
5   //Technology.
6   
7   //This software may be subject to U.S. export control laws. By 
8   //accepting this software, the user agrees to comply with all 
9   //applicable U.S. export laws and regulations. User has the 
10  //responsibility to obtain export licenses, or other export authority 
11  //as may be required before exporting such information to foreign 
12  //countries or providing access to foreign persons.
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  }