View Javadoc

1   /*
2      Licensed under the Apache License, Version 2.0 (the "License");
3      you may not use this file except in compliance with the License.
4      You may obtain a copy of the License at
5   
6        http://www.apache.org/licenses/LICENSE-2.0
7   
8      Unless required by applicable law or agreed to in writing, software
9      distributed under the License is distributed on an "AS IS" BASIS,
10     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11     See the License for the specific language governing permissions and
12     limitations under the License.
13  */
14  package uk.nhs.interoperability.util;
15  
16  import java.text.SimpleDateFormat;
17  import java.util.Calendar;
18  
19  /**
20   * The Class HL7Utils.
21   *
22   * @author Michael Odling-Smee
23   * @author Nicholas Jones
24   * @since 0.1
25   */
26  public class HL7Utils {
27  	
28  	/** The Constant HL7_DATE_FORMAT. */
29  	private static final SimpleDateFormat HL7_DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
30  
31  	/**
32  	 * Instantiates a new h l7 utils.
33  	 */
34  	private HL7Utils() {
35  		//prevent direct instantiation
36  	}
37  	
38  	/**
39  	 * Create a new HL7DateTime string of the form
40  	 * <code>201107121534</code> e.g. <code>yyyyMMddHHmm</code> format
41  	 * @return A new HL7 date time string based on the instant the method was called
42  	 */
43  	public static final String getHL7DateTime() {
44  		return HL7_DATE_FORMAT.format(Calendar.getInstance().getTime());
45  	}
46  
47  }