List of usage examples for java.sql Time before
public boolean before(Date when)
From source file:DateUtil.java
/** * Tells you if the date part of a datetime is in a certain time range. *//*from w w w . jav a2 s . c om*/ 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.UIController.java
public void showDateOfToday(boolean useCacheSunset) { Preferences data = this.getCurrentPreferences(); String city = data.get(FIELD_CITY, DEF_CITY); String country = data.get(FIELD_COUNTRY, DEF_COUNTRY); TimeZone tz = TimeZone.getTimeZone(data.get(FIELD_TIMEZONE, DEF_TIMEZONE)); GregorianCalendar gcal = new GregorianCalendar(tz); Time time = this.calculateSunsetForActualLocation(gcal, useCacheSunset); ImladrisCalendar cal;// w ww .ja v a 2 s .c o m String sunsetStr = ""; String locationInfo = ""; if (time == null) { cal = new ImladrisCalendar(gcal); } else { cal = new ImladrisCalendar(time, gcal); /*check if before sunset*/ String gtimeStr = gcal.get(GregorianCalendar.HOUR_OF_DAY) + ":" + gcal.get(GregorianCalendar.MINUTE) + ":" + gcal.get(GregorianCalendar.SECOND); Time gtime = Time.valueOf(gtimeStr); if (gtime.before(time)) { // before sunset sunsetStr = " - before sunset"; } else { // after/during sunset sunsetStr = " - after sunset"; } String sunsetTimeStr = time.toString(); sunsetTimeStr = sunsetTimeStr.substring(0, sunsetTimeStr.length() - 3); sunsetStr += " " + Lang.punctuation.parenthesis_open + "occurring at " + sunsetTimeStr + Lang.punctuation.parenthesis_close; locationInfo = this.makeLocationString(city, country); if (locationInfo.length() > 0) { locationInfo = Lang.punctuation.parenthesis_open + Lang.common.location_label + Lang.punctuation.double_dot + " " + locationInfo + " " + Lang.punctuation.pipe + " " + Lang.common.timezone_label + Lang.punctuation.double_dot + " " + data.get(FIELD_TIMEZONE, DEF_TIMEZONE) + Lang.punctuation.parenthesis_close; } } String gstr = this.gregorianToString(gcal); String istr = cal.toString(); UI ui = this.getUi(); ui.getTodayGregorian().setText(gstr + sunsetStr); ui.getTodayImladris().setText(istr); ui.getLocationInfo().setText(locationInfo); }
From source file:org.sakaiproject.test.section.TimeConversionTest.java
private void checkBefore(TimeObject timeObj, boolean shouldPass) { Time startTime = JsfUtil.convertStringToTime(timeObj.startTime, timeObj.startTimeAm); Time endTime = JsfUtil.convertStringToTime(timeObj.endTime, timeObj.endTimeAm); boolean before = startTime.before(endTime); if (shouldPass) { Assert.assertTrue(before);// w w w .j a v a2 s . c o m } else { Assert.assertTrue(!before); } }