/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ee.tlu.htk.dippler.utils; import java.util.Calendar; /** * * @author raido */ public class Utility { /** * Get calendar instance with current time 00:00:00:00 * * @return Calendar instance for current time */ public static Calendar getCalendarInstance() { Calendar current_date = Calendar.getInstance(); current_date.set(Calendar.HOUR_OF_DAY, 0); current_date.set(Calendar.MINUTE, 0); current_date.set(Calendar.SECOND, 0); current_date.set(Calendar.MILLISECOND, 0); return current_date; } /** * Get calendar instance with preset timestamp * @param seconds * @return Calendar instance for set time */ public static Calendar getCalendarInstance( int seconds ) { Calendar new_date = Calendar.getInstance(); new_date.setTimeInMillis( toMilliseconds( seconds ) ); return new_date; } /** * Get time in seconds * * @return Long timestamp from 1970 */ public static long getTime() { return ( System.currentTimeMillis() / 1000L ); } /** * Convert seconds into milliseconds * @param seconds int timestamp * @return Time in milliseconds */ public static long toMilliseconds( int seconds ) { return seconds * 1000L; } }