当前位置: 首页>>代码示例>>Java>>正文


Java Calendar.setTimeInMillis方法代码示例

本文整理汇总了Java中com.ibm.icu.util.Calendar.setTimeInMillis方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.setTimeInMillis方法的具体用法?Java Calendar.setTimeInMillis怎么用?Java Calendar.setTimeInMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.util.Calendar的用法示例。


在下文中一共展示了Calendar.setTimeInMillis方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setToNearestDate

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private void setToNearestDate(Calendar calendar) {
    if (selectableDays != null) {
        long distance = Long.MAX_VALUE;
        Calendar currentBest = calendar;
        for (Calendar c : selectableDays) {
            long newDistance = Math.abs(calendar.getTimeInMillis() - c.getTimeInMillis());
            if (newDistance < distance) {
                distance = newDistance;
                currentBest = c;
            } else break;
        }
        calendar.setTimeInMillis(currentBest.getTimeInMillis());
        return;
    }

    if (isBeforeMin(calendar)) {
        calendar.setTimeInMillis(mMinDate.getTimeInMillis());
        return;
    }

    if (isAfterMax(calendar)) {
        calendar.setTimeInMillis(mMaxDate.getTimeInMillis());
        return;
    }
}
 
开发者ID:Tabrizian,项目名称:PersianAndroidDateTimePicker,代码行数:26,代码来源:DatePickerDialog.java

示例2: initializeDefaultCenturyStart

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private void initializeDefaultCenturyStart(long baseTime) {
    defaultCenturyBase = baseTime;
    // clone to avoid messing up date stored in calendar object
    // when this method is called while parsing
    Calendar tmpCal = (Calendar)calendar.clone();
    tmpCal.setTimeInMillis(baseTime);
    tmpCal.add(Calendar.YEAR, -80);
    defaultCenturyStart = tmpCal.getTime();
    defaultCenturyStartYear = tmpCal.get(Calendar.YEAR);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:11,代码来源:SimpleDateFormat.java

示例3: testCaptureWithReAuth

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Map<String, Object> testCaptureWithReAuth(DispatchContext dctx, Map<String, ? extends Object> context) {
    Locale locale = (Locale) context.get("locale");
    GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
    GenericValue authTransaction = (GenericValue) context.get("authTrans");
    Debug.logInfo("Test Capture with 2 minute delay failure/re-auth process", module);

    if (authTransaction == null) {
        authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
    }

    if (authTransaction == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingPaymentCannotBeCaptured", locale));
    }
    Timestamp txStamp = authTransaction.getTimestamp("transactionDate");
    Timestamp nowStamp = UtilDateTime.nowTimestamp();

    Map<String, Object> result = ServiceUtil.returnSuccess();
    result.put("captureAmount", context.get("captureAmount"));
    result.put("captureRefNum", UtilDateTime.nowAsString());

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(txStamp.getTime());
    cal.add(Calendar.MINUTE, 2);
    Timestamp twoMinAfter = new Timestamp(cal.getTimeInMillis());
    if (Debug.infoOn()) Debug.logInfo("Re-Auth Capture Test : Tx Date - " + txStamp + " : 2 Min - " + twoMinAfter + " : Now - " + nowStamp, module);

    if (nowStamp.after(twoMinAfter)) {
        result.put("captureResult", Boolean.FALSE);
    } else {
        result.put("captureResult", Boolean.TRUE);
        result.put("captureFlag", "C");
        result.put("captureMessage", UtilProperties.getMessage(resource, "AccountingPaymentTestCaptureWithReauth", locale));
    }

    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:38,代码来源:PaymentGatewayServices.java

示例4: convert

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public java.sql.Date convert(Number obj) throws ConversionException {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(obj.longValue());
    cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return new java.sql.Date(cal.getTimeInMillis());
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:8,代码来源:DateTimeConverters.java

示例5: toCalendar

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Calendar toCalendar(java.sql.Timestamp stamp) {
    Calendar cal = Calendar.getInstance();
    if (stamp != null) {
        cal.setTimeInMillis(stamp.getTime());
    }
    return cal;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:8,代码来源:UtilDateTime.java

示例6: cleanSyncRemoveInfo

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/**
 * Clean EntitySyncRemove Info
 *@param dctx The DispatchContext that this service is operating in
 *@param context Map containing the input parameters
 *@return Map with the result of the service, the output parameters
 */
public static Map<String, Object> cleanSyncRemoveInfo(DispatchContext dctx, Map<String, ? extends Object> context) {
    Debug.logInfo("Running cleanSyncRemoveInfo", module);
    Delegator delegator = dctx.getDelegator();
    Locale locale = (Locale) context.get("locale");

    try {
        // find the largest keepRemoveInfoHours value on an EntitySyncRemove and kill everything before that, if none found default to 10 days (240 hours)
        double keepRemoveInfoHours = 24;

        List<GenericValue> entitySyncRemoveList = EntityQuery.use(delegator).from("EntitySync").queryList();
        for (GenericValue entitySyncRemove: entitySyncRemoveList) {
            Double curKrih = entitySyncRemove.getDouble("keepRemoveInfoHours");
            if (curKrih != null) {
                double curKrihVal = curKrih.doubleValue();
                if (curKrihVal > keepRemoveInfoHours) {
                    keepRemoveInfoHours = curKrihVal;
                }
            }
        }


        int keepSeconds = (int) Math.floor(keepRemoveInfoHours * 3600);

        Calendar nowCal = Calendar.getInstance();
        nowCal.setTimeInMillis(System.currentTimeMillis());
        nowCal.add(Calendar.SECOND, -keepSeconds);
        Timestamp keepAfterStamp = new Timestamp(nowCal.getTimeInMillis());

        int numRemoved = delegator.removeByCondition("EntitySyncRemove", EntityCondition.makeCondition(ModelEntity.STAMP_TX_FIELD, EntityOperator.LESS_THAN, keepAfterStamp));
        Debug.logInfo("In cleanSyncRemoveInfo removed [" + numRemoved + "] values with TX timestamp before [" + keepAfterStamp + "]", module);

        return ServiceUtil.returnSuccess();
    } catch (GenericEntityException e) {
        Debug.logError(e, "Error cleaning out EntitySyncRemove info: " + e.toString(), module);
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorCleaningEntitySyncRemove", UtilMisc.toMap("errorString", e.toString()), locale));
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:44,代码来源:EntitySyncServices.java

示例7: addUomTime

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Calendar addUomTime(Calendar cal, Timestamp startTime, String uomId, int value) {
    if (cal == null) {
        cal = Calendar.getInstance();
    }
    if (startTime != null) {
        cal.setTimeInMillis(startTime.getTime());
    }
    int[] conv = uomTimeToCalTime(uomId);

    // conversion multiplier * value by type
    cal.add(conv[0], (value * conv[1]));
    return cal;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:14,代码来源:UomWorker.java

示例8: assertDurationLoop

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private static TimeDuration assertDurationLoop(String label, Calendar right, int years, int months, int days, int hours, int minutes, int seconds, int milliseconds, TimeDuration lastString, boolean isNegative) {
    StringBuilder sb = new StringBuilder();
    sb.append(years != 0 ? years : "");
    sb.append(':').append(months != 0 ? months : "");
    sb.append(':').append(days != 0 ? days : "");
    sb.append(':').append(hours != 0 ? hours : "");
    sb.append(':').append(minutes != 0 ? minutes : "");
    sb.append(':').append(seconds != 0 ? seconds : "");
    sb.append(':').append(milliseconds != 0 ? milliseconds : "");
    String durationString = years + ":" + months + ":" + days + ":" + hours + ":" + minutes + ":" + seconds + ":" + milliseconds;
    TimeDuration stringDuration = TimeDuration.parseDuration(sb.toString());
    right.setTimeInMillis(0);
    if (years != 0) {
        right.set(Calendar.YEAR, 1970 + Math.abs(years));
    }
    if (months != 0) {
        right.set(Calendar.MONTH, Math.abs(months));
    }
    right.set(Calendar.DAY_OF_MONTH, Math.abs(days) + 1);
    if (hours != 0) {
        right.set(Calendar.HOUR, Math.abs(hours));
    }
    if (minutes != 0) {
        right.set(Calendar.MINUTE, Math.abs(minutes));
    }
    if (seconds != 0) {
        right.set(Calendar.SECOND, Math.abs(seconds));
    }
    if (milliseconds != 0) {
        right.set(Calendar.MILLISECOND, Math.abs(milliseconds));
    }
    TimeDuration calDuration = isNegative ? new TimeDuration(right, zero) : new TimeDuration(zero, right);
    assertDurationFields(label + "(parseString[0])", years, months, days, hours, minutes, seconds, milliseconds, durationString, TimeDuration.parseDuration(durationString), isNegative, false);
    assertDurationFields(label + "(parseString)", years, months, days, hours, minutes, seconds, milliseconds, durationString, stringDuration, isNegative, false);
    assertDurationFields(label + "(cal)", years, months, days, hours, minutes, seconds, milliseconds, durationString, calDuration, isNegative, false);
    Calendar added = calDuration.addToCalendar((Calendar) zero.clone());
    TimeDuration addDuration = new TimeDuration(zero, added);
    assertDurationFields(label + "(cal[add])", years, months, days, hours, minutes, seconds, milliseconds, durationString, addDuration, isNegative, false);
    assertEquals(label + ".compareTo(string, cal)", 0, doCompare(stringDuration, calDuration));
    assertEquals(label + ".compareTo(string, string)", 0, doCompare(stringDuration, stringDuration));
    assertEquals(label + ".compareTo(cal, cal)", 0, doCompare(calDuration, calDuration));
    assertEquals(label + ".compareTo(cal, string)", 0, doCompare(calDuration, stringDuration));
    assertEquals(label + ".equals(cal, cal)", calDuration, calDuration);
    assertEquals(label + ".equals(cal, string)", calDuration, stringDuration);
    assertEquals(label + ".equals(string, cal)", stringDuration, calDuration);
    assertEquals(label + ".equals(string, string)", stringDuration, stringDuration);
    assertFalse(label + ".not-equals(string, this)", stringDuration.equals(TimeDurationTests.class));
    if (lastString != null) {
        assertFalse(label + ".not-equals(string, lastString)", stringDuration.equals(lastString));
    }
    return stringDuration;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:53,代码来源:TimeDurationTests.java

示例9: getTimeUntilAlarmDisplayString

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static String getTimeUntilAlarmDisplayString(Context context, long timeUntilAlarm) {
    Calendar calendarNow = Calendar.getInstance();
    Calendar calendarAlarm = Calendar.getInstance();
    calendarAlarm.setTimeInMillis(timeUntilAlarm);
    Date alarmTime = calendarAlarm.getTime();

    // It's very important we make the fieldDifference calls in this order.  Each time
    // calendarNow moves closer to alarmTime by the difference units it returns. This implies
    // that you start with the largest calendar unit and move to smaller ones if you want
    // accurate results for different units between the two times.
    int days = Math.max(0, calendarNow.fieldDifference(alarmTime, Calendar.DATE));
    int hours = Math.max(0, calendarNow.fieldDifference(alarmTime, Calendar.HOUR_OF_DAY));
    int minutes = Math.max(0, calendarNow.fieldDifference(alarmTime, Calendar.MINUTE));

    Map<String,Integer> args = new HashMap<>();
    try {
        args.put("days", days);
        args.put("hours", hours);
        args.put("minutes", minutes);
    } catch (Exception e) {
        Logger.trackException(e);
    }

    int resourceIdForDisplayString;
    if (days > 0) {
        if (hours > 0 && minutes > 0) {
            resourceIdForDisplayString = R.string.alarm_set_day_hour_minute;
        } else if (hours > 0) {
            resourceIdForDisplayString = R.string.alarm_set_day_hour;
        } else if (minutes > 0) {
            resourceIdForDisplayString = R.string.alarm_set_day_minute;
        } else {
            resourceIdForDisplayString = R.string.alarm_set_day;
        }
    } else if (hours > 0) {
        if (minutes > 0) {
            resourceIdForDisplayString = R.string.alarm_set_hour_minute;
        } else {
            resourceIdForDisplayString = R.string.alarm_set_hour;
        }
    } else if (minutes > 0) {
        resourceIdForDisplayString = R.string.alarm_set_minute;
    } else {
        resourceIdForDisplayString = R.string.alarm_set_less_than_minute;
    }
    return new MessageFormat(context.getString(resourceIdForDisplayString)).format(args);
}
 
开发者ID:Microsoft,项目名称:ProjectOxford-Apps-MimickerAlarm,代码行数:48,代码来源:DateTimeUtilities.java


注:本文中的com.ibm.icu.util.Calendar.setTimeInMillis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。