package eu.stork.documentservice.data;

public class DatabaseHelper {
	/**
	 * Get the current timestamp in SQL timestamp
	 * @return the current time in sql timestamp
	 */
	public static java.sql.Timestamp getSqlCurrentDate() {
	    java.util.Date today = new java.util.Date();
	    return new java.sql.Timestamp(today.getTime());
	}
	
	/**
	 * Convert Java Date to SQL timestamp
	 * @param date the date to convert
	 * @return the date in sql timestamp
	 */
	public static java.sql.Timestamp getSqlDate(java.util.Date date) {
		if (date != null)
			return new java.sql.Timestamp(date.getTime());
		else
			return null;
	}

	/**
	 * Convert SQL timestamp to Java Date
	 * @param time the timestamp to concert
	 * @return the time in util date
	 */
	public static java.util.Date getUtilDate(java.sql.Timestamp time) {
		if (time != null)
			return new java.util.Date(time.getTime());
		else
			return null;
	}

}