List of usage examples for java.util Date getHours
@Deprecated public int getHours()
From source file:DateUtil.java
/** * Tells you if the date part of a datetime is in a certain time range. *///ww w . j a v a 2s .c o m public static boolean isTimeInRange(java.sql.Time start, java.sql.Time end, java.util.Date d) { d = new java.sql.Time(d.getHours(), d.getMinutes(), d.getSeconds()); if (start == null || end == null) { return false; } if (start.before(end) && (!(d.after(start) && d.before(end)))) { return false; } if (end.before(start) && (!(d.after(end) || d.before(start)))) { return false; } return true; }
From source file:Main.java
static public void appendDateNode(Document owner, Element appendElement, String name, Date date) { Element dateElem = owner.createElement(name); appendElement.appendChild(dateElem); appendSingleValElement(owner, dateElem, "month", Integer.toString(date.getMonth() + 1)); appendSingleValElement(owner, dateElem, "day", Integer.toString(date.getDate())); appendSingleValElement(owner, dateElem, "year", Integer.toString(date.getYear() + 1900)); appendSingleValElement(owner, dateElem, "hour", Integer.toString(date.getHours())); appendSingleValElement(owner, dateElem, "minute", Integer.toString(date.getMinutes())); appendSingleValElement(owner, dateElem, "second", Integer.toString(date.getSeconds())); }
From source file:Main.java
public static String getXMLDateString() { Date date = new Date(); // YYYY-MM-DDThh:mm:ss // Must be a simpler way to do this.... String xmlDateFormat = "" + (date.getYear() + 1900); int month = (date.getMonth() + 1); String monthStr = fillZero(month); String dateStr = fillZero(date.getDate()); xmlDateFormat = xmlDateFormat + "-" + monthStr; xmlDateFormat = xmlDateFormat + "-" + dateStr; xmlDateFormat = xmlDateFormat + "T" + fillZero(date.getHours()); xmlDateFormat = xmlDateFormat + ":" + fillZero(date.getMinutes()); xmlDateFormat = xmlDateFormat + ":" + fillZero(date.getSeconds()); return (xmlDateFormat); }
From source file:DateUtil.java
/** * Checks the hour, minute and second are equal. *///ww w . j a v a 2 s . co m public static boolean timeEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) return false; return d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes() && d1.getSeconds() == d2.getSeconds(); }
From source file:com.bjorsond.android.timeline.utilities.Utilities.java
public static int convertZoomTypeAndDateToZoomValue(Zoom zoom, Date date) { switch (zoom.getType()) { case HOUR_MODE: return date.getHours(); case DAY_MODE: return date.getDate(); case WEEK_MODE: return getWeekNumberOfDate(date); case MONTH_MODE: return getMonthNumberOfDate(date); default:// w w w . jav a2 s .com return -1; } }
From source file:org.nuclos.common2.DateUtils.java
/** * @param date is not altered.//w w w . j ava2 s . c om * @return Is the given date pure? * @precondition date != null * @postcondition result --> date.getHours() == 0 * @postcondition result --> date.getMinutes() == 0 * @postcondition result --> date.getSeconds() == 0 * @see #getPureDate(Date) */ public static boolean isPure(Date date) { final boolean result = date.equals(getPureDate(date)); assert !result || date.getHours() == 0; assert !result || date.getMinutes() == 0; assert !result || date.getSeconds() == 0; return result; }
From source file:DateUtil.java
/** * Checks the second, hour, month, day, month and year are equal. */// w w w. j a va 2 s .c o m public static boolean dateTimeEquals(java.util.Date d1, java.util.Date d2) { if (d1 == null || d2 == null) return false; return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear() && d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes() && d1.getSeconds() == d2.getSeconds(); }
From source file:com.fluidops.iwb.api.ValueResolver.java
/** * Converts a system date like '2011-03-31T19:54:33' to user-readable date. * If the input is not a valid system date, the value is returned as is. * //from w w w . j a v a2s . c o m * @param sysdate * @return */ public static String resolveSysDate(String sysdate) { Date d = ReadDataManagerImpl.ISOliteralToDate(sysdate); if (d == null) return StringEscapeUtils.escapeHtml(sysdate); DateFormat df = null; if (d.getHours() == 0 && d.getMinutes() == 0 && d.getSeconds() == 0) df = new SimpleDateFormat("MMMMM dd, yyyy"); else df = new SimpleDateFormat("MMMMM dd, yyyy, HH:mm:ss"); return df.format(d); }
From source file:com.eryansky.common.utils.StringUtils.java
/** * ???/*from w w w . jav a2s . c om*/ * * @param time * @return */ @SuppressWarnings("deprecation") public static String processTime(Long time) { long oneDay = 24 * 60 * 60 * 1000; Date now = new Date(); Date orginalTime = new Date(time); long nowDay = now.getTime() - (now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()) * 1000; long yesterday = nowDay - oneDay; String nowHourAndMinute = toDoubleDigit(orginalTime.getHours()) + ":" + toDoubleDigit(orginalTime.getMinutes()); if (time >= now.getTime()) { return ""; } else if ((now.getTime() - time) < (60 * 1000)) { return (now.getTime() - time) / 1000 + "? " + nowHourAndMinute + " "; } else if ((now.getTime() - time) < (60 * 60 * 1000)) { return (now.getTime() - time) / 1000 / 60 + "? " + nowHourAndMinute + " "; } else if ((now.getTime() - time) < (24 * 60 * 60 * 1000)) { return (now.getTime() - time) / 1000 / 60 / 60 + "?? " + nowHourAndMinute + " "; } else if (time >= nowDay) { return " " + nowHourAndMinute; } else if (time >= yesterday) { return " " + nowHourAndMinute; } else { return toDoubleDigit(orginalTime.getMonth()) + "-" + toDoubleDigit(orginalTime.getDate()) + " " + nowHourAndMinute + ":" + toDoubleDigit(orginalTime.getSeconds()); } }
From source file:com.cssweb.quote.util.Utils.java
public static String format(Date date) { String str = ""; str = date.getYear() + "-" + formatTwo(date.getMonth() + 1) + "-" + formatTwo(date.getDate()) + " " + formatTwo(date.getHours()) + ":" + formatTwo(date.getMinutes()) + ":00"; return str;//from w ww.ja v a2 s . com }