java.util.Date#setSeconds ( )源码实例Demo

下面列出了java.util.Date#setSeconds ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: doov   文件: DateTypeAdapter.java
@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;
}
 
源代码2 项目: openjdk-jdk9   文件: DurationTest.java
@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();
    }
}
 
源代码3 项目: Android-Allocine-Api   文件: Horaires.java
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;
        }
}
 
源代码4 项目: JavaRush   文件: Solution.java
@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;
}
 
源代码5 项目: viritin   文件: MDateField.java
@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);
}
 
源代码6 项目: UltimateAndroid   文件: MeetingDAO.java
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;
}
 
源代码7 项目: UltimateAndroid   文件: MeetingDAO.java
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;
}
 
源代码8 项目: front50   文件: GcsStorageService.java
@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);
  }
}
 
源代码9 项目: flink-learning   文件: DateUtilTests.java
@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());
}
 
源代码10 项目: flink-learning   文件: DateUtilTests.java
@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());
}
 
源代码11 项目: flink-learning   文件: DateUtilTests.java
@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());
}
 
源代码12 项目: Albianj2   文件: AlbianDateTime.java
@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;
}
 
源代码13 项目: Cirrus_depricated   文件: DisplayUtils.java
@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];
}
 
源代码14 项目: datacollector   文件: TimeNowEL.java
@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;
}
 
源代码15 项目: j2objc   文件: DateTest.java
/**
 * 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());
}
 
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;
}
 
源代码17 项目: es   文件: CalendarService.java
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);
}
 
@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;
}
 
@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;
}
 
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;
}