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  // $Id: ToolsTime.java 3461 2008-08-07 17:43:26Z pramirez $
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  }