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


Java Calendar.getTimeInMillis方法代码示例

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


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

示例1: convert

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public java.sql.Date convert(String obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
    String trimStr = obj.trim();
    if (trimStr.length() == 0) {
        return null;
    }
    DateFormat df = null;
    if (UtilValidate.isEmpty(formatString)) {
        df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, locale);
    } else {
        df = UtilDateTime.toDateFormat(formatString, timeZone, locale);
    }
    try {
        java.util.Date parsedDate = df.parse(trimStr);
        Calendar cal = UtilDateTime.toCalendar(parsedDate, timeZone, locale);
        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());
    } catch (ParseException e) {
        throw new ConversionException(e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:22,代码来源:DateTimeConverters.java

示例2: ObjectTypeTests

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public ObjectTypeTests(String name) {
    super(name);
    ntstmp = new Timestamp(781L);
    ntstmp.setNanos(123000000);
    list = new ArrayList<Object>();
    list.add("one");
    list.add("two");
    list.add("three");
    map = new LinkedHashMap<String, Object>();
    map.put("one", "1");
    map.put("two", "2");
    map.put("three", "3");
    set = new LinkedHashSet<Object>(list);
    Calendar cal = UtilDateTime.getCalendarInstance(localeData.goodTimeZone, localeData.goodLocale);
    cal.set(1969, Calendar.DECEMBER, 31, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    sqlDt = new java.sql.Date(cal.getTimeInMillis());
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:19,代码来源:ObjectTypeTests.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: testDateTimeConverters

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public void testDateTimeConverters() throws Exception {
    Calendar cal = Calendar.getInstance();
    long currentTime = cal.getTimeInMillis();
    cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    long longTime = cal.getTimeInMillis(); // Start of day today
    assertNotEquals("currentTime and longTime are not equal", currentTime, longTime);
    java.util.Date utilDate = new java.util.Date(longTime);
    java.sql.Date sqlDate = new java.sql.Date(longTime);
    java.sql.Timestamp timestamp = new java.sql.Timestamp(longTime);
    // Source class = java.util.Date
    assertConversion("DateToLong", new DateTimeConverters.DateToLong(), utilDate, longTime);
    assertConversion("DateToSqlDate", new DateTimeConverters.DateToSqlDate(), utilDate, new java.sql.Date(longTime));
    assertConversion("DateToString", new DateTimeConverters.DateToString(), utilDate, utilDate.toString());
    assertConversion("DateToTimestamp", new DateTimeConverters.DateToTimestamp(), utilDate, timestamp);
    // Source class = java.sql.Date
    assertConversion("SqlDateToLong", new DateTimeConverters.DateToLong(), sqlDate, longTime);
    assertConversion("SqlDateToDate", new DateTimeConverters.SqlDateToDate(), sqlDate, utilDate);
    assertConversion("SqlDateToString", new DateTimeConverters.SqlDateToString(), sqlDate, sqlDate.toString());
    assertConversion("SqlDateToTimestamp", new DateTimeConverters.SqlDateToTimestamp(), sqlDate, timestamp);
    // Source class = java.sql.Timestamp
    assertConversion("TimestampToLong", new DateTimeConverters.DateToLong(), timestamp, longTime);
    assertConversion("TimestampToDate", new DateTimeConverters.TimestampToDate(), timestamp, utilDate);
    assertConversion("TimestampToSqlDate", new DateTimeConverters.TimestampToSqlDate(), timestamp, sqlDate);
    assertConversion("TimestampToString", new DateTimeConverters.TimestampToString(), timestamp, timestamp.toString());
    // Source class = java.lang.Long
    assertConversion("LongToDate", new DateTimeConverters.NumberToDate(), longTime, utilDate);
    assertConversion("LongToSqlDate", new DateTimeConverters.NumberToSqlDate(), longTime, sqlDate);
    assertConversion("LongToSqlDate", new DateTimeConverters.NumberToSqlDate(), currentTime, sqlDate); //Test conversion to start of day
    assertConversion("LongToTimestamp", new DateTimeConverters.NumberToTimestamp(), longTime, timestamp);
    // Source class = java.lang.String
    assertConversion("StringToTimestamp", new DateTimeConverters.StringToTimestamp(), timestamp.toString(), timestamp);
    //assertConversion("StringToDate", new DateTimeConverters.StringToDate(), utilDate.toString(), utilDate);
    //assertConversion("StringToSqlDate", new DateTimeConverters.StringToSqlDate(), sqlDate.toString(), sqlDate);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:36,代码来源:DateTimeTests.java

示例5: getHourStart

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getHourStart(Timestamp stamp, int hoursLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), tempCal.get(Calendar.HOUR_OF_DAY), 0, 0);
    tempCal.add(Calendar.HOUR_OF_DAY, hoursLater);
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:UtilDateTime.java

示例6: getHourEnd

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getHourEnd(Timestamp stamp, Long hoursLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), tempCal.get(Calendar.HOUR_OF_DAY), 59, 59);
    tempCal.add(Calendar.HOUR_OF_DAY, hoursLater.intValue());
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:UtilDateTime.java

示例7: getDayStart

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getDayStart(Timestamp stamp, int daysLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:UtilDateTime.java

示例8: getDayEnd

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getDayEnd(Timestamp stamp, Long daysLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
    tempCal.add(Calendar.DAY_OF_MONTH, daysLater.intValue());
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    //MSSQL datetime field has accuracy of 3 milliseconds and setting the nano seconds cause the date to be rounded to next day
    //retStamp.setNanos(999999999);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:11,代码来源:UtilDateTime.java

示例9: getWeekStart

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getWeekStart(Timestamp stamp, int daysLater, int weeksLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
    tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek());
    tempCal.add(Calendar.WEEK_OF_MONTH, weeksLater);
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:11,代码来源:UtilDateTime.java

示例10: getMonthStart

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getMonthStart(Timestamp stamp, int daysLater, int monthsLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), 1, 0, 0, 0);
    tempCal.add(Calendar.MONTH, monthsLater);
    tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:10,代码来源:UtilDateTime.java

示例11: getYearStart

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp getYearStart(Timestamp stamp, int daysLater, int monthsLater, int yearsLater, TimeZone timeZone, Locale locale) {
    Calendar tempCal = toCalendar(stamp, timeZone, locale);
    tempCal.set(tempCal.get(Calendar.YEAR), Calendar.JANUARY, 1, 0, 0, 0);
    tempCal.add(Calendar.YEAR, yearsLater);
    tempCal.add(Calendar.MONTH, monthsLater);
    tempCal.add(Calendar.DAY_OF_MONTH, daysLater);
    Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
    retStamp.setNanos(0);
    return retStamp;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:11,代码来源:UtilDateTime.java

示例12: prepareCal

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
protected Calendar prepareCal(Calendar cal) {
    // Performs a "sane" skip forward in time - avoids time consuming loops
    // like incrementing every second from Jan 1 2000 until today
    Calendar skip = (Calendar) cal.clone();
    skip.setTime(this.start);
    long deltaMillis = cal.getTimeInMillis() - this.start.getTime();
    if (deltaMillis < 1000) {
        return skip;
    }
    long divisor = deltaMillis;
    if (this.freqType == Calendar.DAY_OF_MONTH) {
        divisor = 86400000;
    } else if (this.freqType == Calendar.HOUR) {
        divisor = 3600000;
    } else if (this.freqType == Calendar.MINUTE) {
        divisor = 60000;
    } else if (this.freqType == Calendar.SECOND) {
        divisor = 1000;
    } else {
        return skip;
    }
    long units = deltaMillis / divisor;
    units -= units % this.freqCount;
    skip.add(this.freqType, (int)units);
    while (skip.after(cal)) {
        skip.add(this.freqType, -this.freqCount);
    }
    return skip;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:30,代码来源:TemporalExpressions.java

示例13: 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

示例14: makeParamValueFromComposite

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/**
 * Given the prefix of a composite parameter, recomposes a single Object from
 * the composite according to compositeType. For example, consider the following
 * form widget field,
 *
 *   <field name="meetingDate">
 *     <date-time type="timestamp" input-method="time-dropdown">
 *   </field>
 *
 * The result in HTML is three input boxes to input the date, hour and minutes separately.
 * The parameter names are named meetingDate_c_date, meetingDate_c_hour, meetingDate_c_minutes.
 * Additionally, there will be a field named meetingDate_c_compositeType with a value of "Timestamp".
 * where _c_ is the COMPOSITE_DELIMITER. These parameters will then be recomposed into a Timestamp
 * object from the composite fields.
 *
 * @param request
 * @param prefix
 * @return Composite object from data or null if not supported or a parsing error occurred.
 */
public static Object makeParamValueFromComposite(HttpServletRequest request, String prefix, Locale locale) {
    String compositeType = request.getParameter(makeCompositeParam(prefix, "compositeType"));
    if (UtilValidate.isEmpty(compositeType)) return null;

    // collect the composite fields into a map
    Map<String, String> data = new HashMap<String, String>();
    for (Enumeration<String> names = UtilGenerics.cast(request.getParameterNames()); names.hasMoreElements();) {
        String name = names.nextElement();
        if (!name.startsWith(prefix + COMPOSITE_DELIMITER)) continue;

        // extract the suffix of the composite name
        String suffix = name.substring(name.indexOf(COMPOSITE_DELIMITER) + COMPOSITE_DELIMITER_LENGTH);

        // and the value of this parameter
        String value = request.getParameter(name);

        // key = suffix, value = parameter data
        data.put(suffix, value);
    }
    if (Debug.verboseOn()) { Debug.logVerbose("Creating composite type with parameter data: " + data.toString(), module); }

    // handle recomposition of data into the compositeType
    if ("Timestamp".equals(compositeType)) {
        String date = data.get("date");
        String hour = data.get("hour");
        String minutes = data.get("minutes");
        String ampm = data.get("ampm");
        if (date == null || date.length() < 10) return null;
        if (UtilValidate.isEmpty(hour)) return null;
        if (UtilValidate.isEmpty(minutes)) return null;
        boolean isTwelveHour = UtilValidate.isNotEmpty(ampm);

        // create the timestamp from the data
        try {
            int h = Integer.parseInt(hour);
            Timestamp timestamp = Timestamp.valueOf(date.substring(0, 10) + " 00:00:00.000");
            Calendar cal = Calendar.getInstance(locale);
            cal.setTime(timestamp);
            if (isTwelveHour) {
                boolean isAM = ("AM".equals(ampm) ? true : false);
                if (isAM && h == 12) h = 0;
                if (!isAM && h < 12) h += 12;
            }
            cal.set(Calendar.HOUR_OF_DAY, h);
            cal.set(Calendar.MINUTE, Integer.parseInt(minutes));
            return new Timestamp(cal.getTimeInMillis());
        } catch (IllegalArgumentException e) {
            Debug.logWarning("User input for composite timestamp was invalid: " + e.getMessage(), module);
            return null;
        }
    }

    // we don't support any other compositeTypes (yet)
    return null;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:75,代码来源:UtilHttp.java

示例15: adjustTimestamp

import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Timestamp adjustTimestamp(Timestamp stamp, Integer adjType, Integer adjQuantity) {
    Calendar tempCal = toCalendar(stamp);
    tempCal.add(adjType, adjQuantity);
    return new Timestamp(tempCal.getTimeInMillis());
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:6,代码来源:UtilDateTime.java


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