Java Code Examples for java.util.Date#setSeconds()
The following examples show how to use
java.util.Date#setSeconds() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTypeAdapter.java From doov with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("deprecation") public Object fromString(FieldInfo info, String value) { int year = Integer.parseInt(value.substring(0, 4)); int month = Integer.parseInt(value.substring(4, 6)); int day = Integer.parseInt(value.substring(6, 8)); Date date = new Date(); date.setDate(day); date.setMonth(month - 1); date.setYear(year - 1900); date.setHours(0); date.setMinutes(0); date.setSeconds(0); return date; }
Example 2
Source File: GcsStorageService.java From front50 with Apache License 2.0 | 6 votes |
@VisibleForTesting public void scheduleWriteLastModified(String daoTypeName) { Date when = new Date(); when.setSeconds(when.getSeconds() + 2); GcsStorageService service = this; Runnable task = new Runnable() { public void run() { // Release the scheduled update lock, and perform the actual update scheduledUpdateLock(daoTypeName).set(false); log.info("RUNNING {}", daoTypeName); service.writeLastModified(daoTypeName); } }; if (scheduledUpdateLock(daoTypeName).compareAndSet(false, true)) { log.info("Scheduling deferred update {} timestamp.", daoTypeName); taskScheduler.schedule(task, when); } }
Example 3
Source File: DurationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testDurationAndCalendar3() { try { Calendar cal = new GregorianCalendar(); cal.set(Calendar.SECOND, 59); DatatypeFactory.newInstance().newDuration(10000).addTo(cal); AssertJUnit.assertTrue("sec will be 9", cal.get(Calendar.SECOND) == 9); Date date = new Date(); date.setSeconds(59); DatatypeFactory.newInstance().newDuration(10000).addTo(date); AssertJUnit.assertTrue("sec will be 9", date.getSeconds() == 9); } catch (DatatypeConfigurationException e) { e.printStackTrace(); } }
Example 4
Source File: Horaires.java From Android-Allocine-Api with Apache License 2.0 | 6 votes |
public boolean isMoreThanToday() { try { String dateFormatted = getDate(); Date now = new Date(); now.setHours(0); now.setSeconds(0); now.setMinutes(0); SimpleDateFormat formater = new SimpleDateFormat("E dd MMMMM yyyy", Locale.FRANCE); Date date = formater.parse(dateFormatted); date.setHours(13); return date.equals(now) || date.after(now); } catch (Exception e) { e.printStackTrace(); return false; } }
Example 5
Source File: MeetingDAO.java From UltimateAndroid with Apache License 2.0 | 6 votes |
public Meeting findByTeamAndDate(Team team, Date date) { Cursor cursor = null; Meeting meeting = null; try { long startTime = date.getTime(); Date endDate = new Date(date.getTime()); endDate.setSeconds(endDate.getSeconds() + 1); long endTime = endDate.getTime(); SQLiteDatabase db = getReadableDatabase(); cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, MEETINGS_TEAM_NAME + " = ? and " + MEETINGS_MEETING_TIME + " >= ? and " + MEETINGS_MEETING_TIME + " < ?", new String[] {team.getName(), Long.toString(startTime), Long.toString(endTime)}, null, null, null); if (cursor.getCount() == 1) { if (cursor.moveToFirst()) { meeting = createMeetingFromCursorData(cursor); } } } finally { closeCursor(cursor); } return meeting; }
Example 6
Source File: MeetingDAO.java From UltimateAndroid with Apache License 2.0 | 6 votes |
public Meeting findByTeamAndDate(Team team, Date date) { Cursor cursor = null; Meeting meeting = null; try { long startTime = date.getTime(); Date endDate = new Date(date.getTime()); endDate.setSeconds(endDate.getSeconds() + 1); long endTime = endDate.getTime(); SQLiteDatabase db = getReadableDatabase(); cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, MEETINGS_TEAM_NAME + " = ? and " + MEETINGS_MEETING_TIME + " >= ? and " + MEETINGS_MEETING_TIME + " < ?", new String[] {team.getName(), Long.toString(startTime), Long.toString(endTime)}, null, null, null); if (cursor.getCount() == 1) { if (cursor.moveToFirst()) { meeting = createMeetingFromCursorData(cursor); } } } finally { closeCursor(cursor); } return meeting; }
Example 7
Source File: MDateField.java From viritin with Apache License 2.0 | 6 votes |
@Override protected void setValue(Date newValue, boolean repaintIsNotNeeded) throws ReadOnlyException { if (settingInitialValue && getResolution().ordinal() > Resolution.HOUR.ordinal()) { if (getInitialTimeMode() == InitialTimeMode.START_OF_DAY) { newValue.setHours(0); newValue.setMinutes(0); newValue.setSeconds(0); newValue.setTime( newValue.getTime() - newValue.getTime() % 1000l); } else if (getInitialTimeMode() == InitialTimeMode.END_OF_DAY) { newValue.setHours(23); newValue.setMinutes(59); newValue.setSeconds(59); newValue.setTime( newValue.getTime() - newValue.getTime() % 1000l + 999l); } } super.setValue(newValue, repaintIsNotNeeded); }
Example 8
Source File: Solution.java From JavaRush with MIT License | 6 votes |
@SuppressWarnings("deprecation") private static boolean isDateOdd(String date) { boolean bool; Date date1 = new Date(date); Date ms = new Date(date); ms.setHours(0); ms.setMinutes(0); ms.setSeconds(0); ms.setMonth(0); ms.setDate(1); long num = date1.getTime() - ms.getTime(); long dayMs = 24 * 60 * 60 * 1000; int day = (int) (num / dayMs); bool = day % 2 == 0; return bool; }
Example 9
Source File: DateTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * java.util.Date#setSeconds(int) */ public void test_setSecondsI() { // Test for method void java.util.Date.setSeconds(int) Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setSeconds(13); assertEquals("Set incorrect seconds", 13, d.getSeconds()); }
Example 10
Source File: HotelDataValidateTester.java From eLong-OpenAPI-JAVA-demo with Apache License 2.0 | 5 votes |
@Override public ValidateCondition getConditon() { ValidateCondition condition = new ValidateCondition(); Date date = new Date(); Date date2 = util.Tool.addDate(date, 1); Date date3 = new Date(); date3.setHours(15); date3.setMinutes(0); date3.setSeconds(0); Date date4 = new Date(); date4.setHours(17); date4.setMinutes(0); date4.setSeconds(0); condition.setArrivalDate(date); condition.setDepartureDate(date2); condition.setHotelId("10101129"); condition.setRoomTypeId("0001"); condition.setRatePlanId(90257); condition.setNumberOfRooms(1); condition.setTotalPrice(new BigDecimal(500)); condition.setEarliestArrivalTime(date3); condition.setLatestArrivalTime(date4); return condition; }
Example 11
Source File: CalendarService.java From es with Apache License 2.0 | 5 votes |
public Long countRecentlyCalendar(Long userId, Integer interval) { Date nowDate = new Date(); Date nowTime = new Time(nowDate.getHours(), nowDate.getMinutes(), nowDate.getSeconds()); nowDate.setHours(0); nowDate.setMinutes(0); nowDate.setSeconds(0); return getCalendarRepository().countRecentlyCalendar(userId, nowDate, nowTime, interval); }
Example 12
Source File: ClientIntervalBuilderDynamicDate.java From dashbuilder with Apache License 2.0 | 5 votes |
protected Date firstIntervalDate(DateIntervalType intervalType, Date minDate, ColumnGroup columnGroup) { Date intervalMinDate = new Date(minDate.getTime()); if (YEAR.equals(intervalType)) { intervalMinDate.setMonth(0); intervalMinDate.setDate(1); intervalMinDate.setHours(0); intervalMinDate.setMinutes(0); intervalMinDate.setSeconds(0); } if (QUARTER.equals(intervalType)) { int currentMonth = intervalMinDate.getMonth(); int firstMonthYear = columnGroup.getFirstMonthOfYear().getIndex(); int rest = Quarter.getPositionInQuarter(firstMonthYear, currentMonth + 1); intervalMinDate.setMonth(currentMonth - rest); intervalMinDate.setDate(1); intervalMinDate.setHours(0); intervalMinDate.setMinutes(0); intervalMinDate.setSeconds(0); } if (MONTH.equals(intervalType)) { intervalMinDate.setDate(1); intervalMinDate.setHours(0); intervalMinDate.setMinutes(0); intervalMinDate.setSeconds(0); } if (DAY.equals(intervalType) || DAY_OF_WEEK.equals(intervalType) || WEEK.equals(intervalType)) { intervalMinDate.setHours(0); intervalMinDate.setMinutes(0); intervalMinDate.setSeconds(0); } if (HOUR.equals(intervalType)) { intervalMinDate.setMinutes(0); intervalMinDate.setSeconds(0); } if (MINUTE.equals(intervalType)) { intervalMinDate.setSeconds(0); } return intervalMinDate; }
Example 13
Source File: TimeNowEL.java From datacollector with Apache License 2.0 | 5 votes |
@ElFunction(prefix = TIME_CONTEXT_VAR, name = "trimTime", description = "Set time portion of datetime expression to 00:00:00") @SuppressWarnings("deprecation") public static Date trimTime(@ElParam("datetime") Date in) { if(in == null) { return null; } Date ret = new Date(in.getTime()); ret.setHours(0); ret.setMinutes(0); ret.setSeconds(0); return ret; }
Example 14
Source File: DisplayUtils.java From Cirrus_depricated with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static CharSequence getRelativeDateTimeString ( Context c, long time, long minResolution, long transitionResolution, int flags ){ CharSequence dateString = ""; // in Future if (time > System.currentTimeMillis()){ return DisplayUtils.unixTimeToHumanReadable(time); } // < 60 seconds -> seconds ago else if ((System.currentTimeMillis() - time) < 60 * 1000) { return c.getString(R.string.file_list_seconds_ago); } else { // Workaround 2.x bug (see https://github.com/owncloud/android/issues/716) if ( Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && (System.currentTimeMillis() - time) > 24 * 60 * 60 * 1000 ) { Date date = new Date(time); date.setHours(0); date.setMinutes(0); date.setSeconds(0); dateString = DateUtils.getRelativeDateTimeString( c, date.getTime(), minResolution, transitionResolution, flags ); } else { dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); } } return dateString.toString().split(",")[0]; }
Example 15
Source File: AlbianDateTime.java From Albianj2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("deprecation") public static Date dateAddSeconds(int year, int month, int day, long second) { Date dt = new Date(); dt.setYear(year - 1900); dt.setMonth(month - 1); dt.setDate(day); dt.setHours(0); dt.setMinutes(0); dt.setSeconds(0); Calendar rightNow = Calendar.getInstance(); rightNow.setTime(dt); rightNow.add(Calendar.SECOND, (int) second); Date dt1 = rightNow.getTime(); return dt1; }
Example 16
Source File: DateUtilTests.java From flink-learning with Apache License 2.0 | 5 votes |
@Test public void testWithTimeAtEndOfNow() { Date date = new Date(); date.setHours(23); date.setMinutes(59); date.setSeconds(59); String data = new SimpleDateFormat("yyyyMMddHHmmss").format(date); Assert.assertEquals(data, DateUtil.withTimeAtEndOfNow()); }
Example 17
Source File: DateUtilTests.java From flink-learning with Apache License 2.0 | 5 votes |
@Test public void testWithTimeAtStartOfNow() { Date date = new Date(); date.setHours(0); date.setMinutes(0); date.setSeconds(0); String data = new SimpleDateFormat("yyyyMMddHHmmss").format(date); Assert.assertEquals(data, DateUtil.withTimeAtStartOfNow()); }
Example 18
Source File: DateUtilTests.java From flink-learning with Apache License 2.0 | 5 votes |
@Test public void testWithTimeAtEndOfNow() { Date date = new Date(); date.setHours(23); date.setMinutes(59); date.setSeconds(59); String data = new SimpleDateFormat("yyyyMMddHHmmss").format(date); Assert.assertEquals(data, DateUtil.withTimeAtEndOfNow()); }
Example 19
Source File: HotelOrderCreateTester.java From eLong-OpenAPI-JAVA-demo with Apache License 2.0 | 4 votes |
@Override public CreateOrderCondition getConditon() { CreateOrderCondition condition = new CreateOrderCondition(); Date date = new Date(); date = util.Tool.addDate(date, 1); Date date2 = util.Tool.addDate(date, 1); Date date3 = util.Tool.addDate(date, 0); date3.setHours(15); date3.setMinutes(0); date3.setSeconds(0); Date date4 = util.Tool.addDate(date, 0); date4.setHours(17); date4.setMinutes(0); date4.setSeconds(0); condition.setHotelId("10101129"); condition.setRoomTypeId("0010"); condition.setRatePlanId(145742); condition.setTotalPrice(new BigDecimal(600)); condition.setAffiliateConfirmationId("my-order-id-2"); condition.setArrivalDate(date); condition.setConfirmationType(elong.EnumConfirmationType.NotAllowedConfirm); condition.setContact(getContact()); condition.setCreditCard(getCreditCard()); condition.setCurrencyCode(elong.EnumCurrencyCode.HKD); condition.setCustomerIPAddress("211.151.230.21"); condition.setCustomerType(elong.EnumGuestTypeCode.OtherForeign); condition.setDepartureDate(date2); condition.setEarliestArrivalTime(date3); condition.setExtendInfo(null); condition.setInvoice(null); condition.setIsForceGuarantee(false); condition.setIsGuaranteeOrCharged(false); condition.setIsNeedInvoice(false); condition.setLatestArrivalTime(date4); condition.setNightlyRates(null); condition.setNoteToElong(""); condition.setNoteToHotel(null); condition.setNumberOfCustomers(1); condition.setNumberOfRooms(1); condition.setOrderRooms( getRooms() ); condition.setPaymentType(elong.EnumPaymentType.SelfPay); condition.setSupplierCardNo(null); return condition; }
Example 20
Source File: ClientIntervalBuilderDynamicDate.java From dashbuilder with Apache License 2.0 | 4 votes |
protected Date nextIntervalDate(Date intervalMinDate, DateIntervalType intervalType, int intervals) { Date intervalMaxDate = new Date(intervalMinDate.getTime()); if (MILLENIUM.equals(intervalType)) { intervalMaxDate.setYear(intervalMinDate.getYear() + 1000 * intervals); } else if (CENTURY.equals(intervalType)) { intervalMaxDate.setYear(intervalMinDate.getYear() + 100 * intervals); } else if (DECADE.equals(intervalType)) { intervalMaxDate.setYear(intervalMinDate.getYear() + 10 * intervals); } else if (YEAR.equals(intervalType)) { intervalMaxDate.setYear(intervalMinDate.getYear() + intervals); } else if (QUARTER.equals(intervalType)) { intervalMaxDate.setMonth(intervalMinDate.getMonth() + 3 * intervals); } else if (MONTH.equals(intervalType)) { intervalMaxDate.setMonth(intervalMinDate.getMonth() + intervals); } else if (WEEK.equals(intervalType)) { intervalMaxDate.setDate(intervalMinDate.getDate() + 7 * intervals); } else if (DAY.equals(intervalType) || DAY_OF_WEEK.equals(intervalType)) { intervalMaxDate.setDate(intervalMinDate.getDate() + intervals); } else if (HOUR.equals(intervalType)) { intervalMaxDate.setHours(intervalMinDate.getHours() + intervals); } else if (MINUTE.equals(intervalType)) { intervalMaxDate.setMinutes(intervalMinDate.getMinutes() + intervals); } else if (SECOND.equals(intervalType)) { intervalMaxDate.setSeconds(intervalMinDate.getSeconds() + intervals); } else { // Default to year to avoid infinite loops intervalMaxDate.setYear(intervalMinDate.getYear() + intervals); } return intervalMaxDate; }