From: <sa...@us...> - 2003-10-21 21:43:20
|
Update of /cvsroot/jrobin/src/jrobin/core In directory sc8-pr-cvs1:/tmp/cvs-serv5285/jrobin/core Modified Files: Util.java Log Message: minor changes Index: Util.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/core/Util.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Util.java 16 Oct 2003 09:26:30 -0000 1.5 --- Util.java 21 Oct 2003 14:42:31 -0000 1.6 *************** *** 27,30 **** --- 27,31 ---- import java.util.Date; import java.util.Locale; + import java.util.GregorianCalendar; /** *************** *** 112,115 **** --- 113,159 ---- } + /** + * Returns timestamp (unix epoch) for the given Date object + * @param date Date object + * @return Corresponding timestamp (without milliseconds) + */ + public static long getTimestamp(Date date) { + return (date.getTime() + 500L) / 1000L; + } + + /** + * Returns timestamp (unix epoch) for the given GregorianCalendar object + * @param gc GregorianCalendar object + * @return Corresponding timestamp (without milliseconds) + */ + public static long getTimestamp(GregorianCalendar gc) { + return getTimestamp(gc.getTime()); + } + + /** + * Returns timestamp (unix epoch) for the given year, month, day, hour and minute. + * @param year Year + * @param month Month (zero-based) + * @param day Day in month + * @param hour Hour + * @param min Minute + * @return Corresponding timestamp + */ + public static long getTimestamp(int year, int month, int day, int hour, int min) { + GregorianCalendar gc = new GregorianCalendar(year, month, day, hour, min); + return Util.getTimestamp(gc); + } + + /** + * Returns timestamp (unix epoch) for the given year, month and day. + * @param year Year + * @param month Month (zero-based) + * @param day Day in month + * @return Corresponding timestamp + */ + public static long getTimestamp(int year, int month, int day) { + return Util.getTimestamp(year, month, day, 0, 0); + } + static double parseDouble(String valueStr) { double value; *************** *** 122,125 **** return value; } - } --- 166,169 ---- return value; } } + |