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


Java Calendar.getTime方法代码示例

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


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

示例1: onDateSet

import java.util.Calendar; //导入方法依赖的package包/类
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear,
                      int dayOfMonth) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, monthOfYear);
    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
    Date date = calendar.getTime();
    preferencesHelper.setCurProgramsDate(getString(R.string.pref_program_date_key), date.getTime());
    getContentResolver().notifyChange(TvContract.ChannelEntry.CONTENT_URI, null);
    updateChannelView();
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:13,代码来源:MainActivity.java

示例2: setupTinaFeyAndSarahPalin

import java.util.Calendar; //导入方法依赖的package包/类
private Patient setupTinaFeyAndSarahPalin() {
    Patient patient = save(new Patient("47"));
    Patient patient2 = save(new Patient("48"));

    on(patient, it -> {
        it.apply(new PatientCreated("Tina Fey"));
        it.apply(new ProcedurePerformed(ANNUAL_PHYSICAL_NAME,
                new BigDecimal(ANNUAL_PHYSICAL_COST)));
        it.apply(new ProcedurePerformed(GLUCOSE_TEST_NAME, new BigDecimal(GLUCOSE_TEST_COST)));

        it.snapshotWith(patientAccountQuery);
        it.snapshotWith(patientHealthQuery);
    });

    on(patient2, it -> {
        final String name = "Sarah Palin";
        it.apply(new PatientCreated(name));
        it.apply(new PaymentMade(new BigDecimal("100.25")));

        it.snapshotWith(patientAccountQuery);
        it.snapshotWith(patientHealthQuery);
    });

    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(currDate);
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    currDate = calendar.getTime();
    final PatientDeprecatedBy mergeEvent = merge(patient, patient2);

    on(patient, it -> it.apply(new PatientEventReverted(mergeEvent.getId())));
    on(patient2, it -> it.apply(new PatientEventReverted(mergeEvent.getConverse().getId())));

    return patient;
}
 
开发者ID:rahulsom,项目名称:grooves,代码行数:35,代码来源:BootStrap.java

示例3: test6

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Test 6 checks that 9am on Sunday 28 March 2004 converts to the timeline 
 * value and back again correctly.  Note that Saturday and Sunday are 
 * excluded from the timeline, so we expect the value to map to 9am on 
 * Monday 29 March 2004. This is during daylight saving.
 */
public void test6() {
    Calendar cal = Calendar.getInstance(Locale.UK);
    cal.set(Calendar.YEAR, 2004);
    cal.set(Calendar.MONTH, Calendar.MARCH);
    cal.set(Calendar.DAY_OF_MONTH, 28);
    cal.set(Calendar.HOUR_OF_DAY, 9);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Date date = cal.getTime();
    SegmentedTimeline timeline = getTimeline();      

    long value = timeline.toTimelineValue(date);   
    long ms = timeline.toMillisecond(value);
    Calendar cal2 = Calendar.getInstance(Locale.UK);
    cal2.setTime(new Date(ms));
    Date reverted = cal2.getTime();
  
    Calendar expectedReverted = Calendar.getInstance(Locale.UK);
    expectedReverted.set(Calendar.YEAR, 2004);
    expectedReverted.set(Calendar.MONTH, Calendar.MARCH);
    expectedReverted.set(Calendar.DAY_OF_MONTH, 29);
    expectedReverted.set(Calendar.HOUR_OF_DAY, 9);
    expectedReverted.set(Calendar.MINUTE, 0);
    expectedReverted.set(Calendar.SECOND, 0);
    expectedReverted.set(Calendar.MILLISECOND, 0);
  
    assertTrue(
        "test6", value == (900000 * 34 * 2) 
        && expectedReverted.getTime().getTime() == reverted.getTime()
    );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:SegmentedTimelineTests2.java

示例4: lookupUserData

import java.util.Calendar; //导入方法依赖的package包/类
private void lookupUserData(String username) {
    try {
        JSONObject user = TwitchAPIv3.instance().GetUser(username);

        if (user.getBoolean("_success")) {
            if (user.getInt("_http") == 200) {
                if (user.getJSONArray("users").length() > 0) {
                    String displayName = user.getJSONArray("users").getJSONObject(0).getString("display_name").replaceAll("\\\\s", " ");
                    String userID = user.getJSONArray("users").getJSONObject(0).getString("_id");
                    cache.put(username, new UserData(displayName, userID));
                }
            } else {
                com.gmt2001.Console.debug.println("UsernameCache.updateCache: Failed to get username [" + username + "] http error [" + user.getInt("_http") + "]");
            }
        } else {
            if (user.getString("_exception").equalsIgnoreCase("SocketTimeoutException") || user.getString("_exception").equalsIgnoreCase("IOException")) {
                Calendar c = Calendar.getInstance();

                if (lastFail.after(new Date())) {
                    numfail++;
                } else {
                    numfail = 1;
                }

                c.add(Calendar.MINUTE, 1);

                lastFail = c.getTime();

                if (numfail >= 5) {
                    timeoutExpire = c.getTime();
                }
            }
        }
    } catch (Exception e) {
        com.gmt2001.Console.err.printStackTrace(e);
    }
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:38,代码来源:UsernameCache.java

示例5: apply

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * The CRL next update time is compared against the current time with the threshold
 * applied and rejected if and only if the next update time is in the past.
 *
 * @param crl CRL instance to evaluate.
 *
 * @throws GeneralSecurityException On expired CRL data. Check the exception type for exact details
 *
 * @see org.jasig.cas.adaptors.x509.authentication.handler.support.RevocationPolicy#apply(java.lang.Object)
 */
@Override
public void apply(final X509CRL crl) throws GeneralSecurityException {
    final Calendar cutoff = Calendar.getInstance();
    if (CertUtils.isExpired(crl, cutoff.getTime())) {
        cutoff.add(Calendar.SECOND, -this.threshold);
        if (CertUtils.isExpired(crl, cutoff.getTime())) {
            throw new ExpiredCRLException(crl.toString(), cutoff.getTime(), this.threshold);
        }
        logger.info(String.format("CRL expired on %s but is within threshold period, %s seconds.",
                    crl.getNextUpdate(), this.threshold));
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:24,代码来源:ThresholdExpiredCRLRevocationPolicy.java

示例6: fastTimeCreate

import java.util.Calendar; //导入方法依赖的package包/类
final static Time fastTimeCreate(Calendar cal, int hour, int minute, int second, ExceptionInterceptor exceptionInterceptor) throws SQLException {
    if (hour < 0 || hour > 24) {
        throw SQLError.createSQLException(
                "Illegal hour value '" + hour + "' for java.sql.Time type in value '" + timeFormattedString(hour, minute, second) + ".",
                SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
    }

    if (minute < 0 || minute > 59) {
        throw SQLError.createSQLException(
                "Illegal minute value '" + minute + "' for java.sql.Time type in value '" + timeFormattedString(hour, minute, second) + ".",
                SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
    }

    if (second < 0 || second > 59) {
        throw SQLError.createSQLException(
                "Illegal minute value '" + second + "' for java.sql.Time type in value '" + timeFormattedString(hour, minute, second) + ".",
                SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
    }

    synchronized (cal) {
        java.util.Date origCalDate = cal.getTime();
        try {
            cal.clear();

            // Set 'date' to epoch of Jan 1, 1970
            cal.set(1970, 0, 1, hour, minute, second);

            long timeAsMillis = cal.getTimeInMillis();

            return new Time(timeAsMillis);
        } finally {
            cal.setTime(origCalDate);
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:36,代码来源:TimeUtil.java

示例7: addDays

import java.util.Calendar; //导入方法依赖的package包/类
private static Date addDays(Date date, int dayCount) {

		Calendar calendar = getCalendar();
		calendar.setTime(date);
		calendar.add(Calendar.DAY_OF_MONTH, dayCount);
		return calendar.getTime();
	}
 
开发者ID:dvbern,项目名称:date-helper,代码行数:8,代码来源:FeiertageHelper.java

示例8: convertHourMinute2Date

import java.util.Calendar; //导入方法依赖的package包/类
public static Date convertHourMinute2Date(int hour, int minute) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, hour);
    cal.set(Calendar.MINUTE, minute);
    cal.set(Calendar.SECOND, 0);

    return cal.getTime();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:9,代码来源:Func.java

示例9: getBeforeDate

import java.util.Calendar; //导入方法依赖的package包/类
public static Date getBeforeDate(String range) {

        Calendar today = Calendar.getInstance();
        if ("week".equalsIgnoreCase(range))
            today.add(Calendar.WEEK_OF_MONTH, -1);
        else if ("month".equalsIgnoreCase(range))
            today.add(Calendar.MONTH, -1);
        else
            today.clear();
        return today.getTime();
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:12,代码来源:DateTimeHelper.java

示例10: main

import java.util.Calendar; //导入方法依赖的package包/类
@SuppressWarnings("static-access")
public static void main(String[] args) {
	// TODO Auto-generated method stub
	Calendar calendar = Calendar.getInstance();
	calendar.add(calendar.DATE, 100); 	// �������ϼ���100��
	Date date=calendar.getTime();		//ת��ΪDate���Ͷ���
	DateFormat fullFormat=DateFormat.getDateInstance(DateFormat.FULL);//FULL��ʽ��DateFormat����
		
	System.out.println(fullFormat.format(date));//DateFormat����ֻ��������Date�࣬����Ҫת��
}
 
开发者ID:TomLao,项目名称:javaPractise,代码行数:11,代码来源:second.java

示例11: fromLocalDateTime

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Convert a {@link LocalDateTime} value into a {@link Date}, using default calendar.
 * @param dateTime Date/time to convert (may be null)
 * @return Converted {@link Date}, or <code>null</code> if given date was <code>null</code>
 */
public static Date fromLocalDateTime(LocalDateTime dateTime) {
	if (dateTime != null) {
		Calendar c = Calendar.getInstance();
		c.set(Calendar.YEAR, dateTime.getYear());
		c.set(Calendar.MONTH, dateTime.getMonthValue() - 1);
		c.set(Calendar.DAY_OF_MONTH, dateTime.getDayOfMonth());
		c.set(Calendar.HOUR_OF_DAY, dateTime.getHour());
		c.set(Calendar.MINUTE, dateTime.getMinute());
		c.set(Calendar.SECOND, dateTime.getSecond());
		c.set(Calendar.MILLISECOND, (int) TimeUnit.NANOSECONDS.toMillis(dateTime.getNano()));
		return c.getTime();
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:20,代码来源:ConversionUtils.java

示例12: toType

import java.util.Calendar; //导入方法依赖的package包/类
@Override
public Date toType(Config config, Date orig) {
    Calendar origCalendar = Calendar.getInstance(UTC);
    origCalendar.setTime(orig);
    Calendar result = Calendar.getInstance(UTC);
    result.setTimeInMillis(0L);
    result.set(Calendar.HOUR_OF_DAY, origCalendar.get(Calendar.HOUR_OF_DAY));
    result.set(Calendar.MINUTE, origCalendar.get(Calendar.MINUTE));
    result.set(Calendar.SECOND, origCalendar.get(Calendar.SECOND));
    result.set(Calendar.MILLISECOND, origCalendar.get(Calendar.MILLISECOND));
    return result.getTime();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:13,代码来源:TimestampConverter.java

示例13: doBlackMagic

import java.util.Calendar; //导入方法依赖的package包/类
private void doBlackMagic(SalesOrderLine sol){
    SalesOrder so = sol.getOrderId();
    Date date = null;

    //all we care about is the day the sale happened
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(so.getDate().getTime());
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE,0);
    cal.set(Calendar.SECOND,0);
    cal.set(Calendar.MILLISECOND,0);
    
    date = cal.getTime();
    
    if (!dailySalesCounter.containsKey(date)){
        dailySalesCounter.put(date, new HashMap<Product, HashMap<String, HashMap<Region, Integer>>>());
    }
    if (!dailySalesCounter.get(date).containsKey(sol.getProductId())){
        dailySalesCounter.get(date).put(sol.getProductId(), new HashMap<String, HashMap<Region, Integer>>());
    }
    if (!dailySalesCounter.get(date).get(sol.getProductId()).containsKey(so.getCustomerId().getAddressId().getStateProvCd())){
        dailySalesCounter.get(date).get(sol.getProductId()).put(so.getCustomerId().getAddressId().getStateProvCd(), new HashMap<Region,Integer>());
    }
    if (!dailySalesCounter.get(date).get(sol.getProductId()).get(so.getCustomerId().getAddressId().getStateProvCd()).containsKey(so.getRegionId())){
        dailySalesCounter.get(date).get(sol.getProductId()).get(so.getCustomerId().getAddressId().getStateProvCd()).put(so.getRegionId(), sol.getQuantity());
    }
    else{
        Integer quantity = dailySalesCounter.get(date).get(sol.getProductId()).get(so.getCustomerId().getAddressId().getStateProvCd()).put(so.getRegionId(), sol.getQuantity());
        quantity = quantity + sol.getQuantity();
        dailySalesCounter.get(date).get(sol.getProductId()).get(so.getCustomerId().getAddressId().getStateProvCd()).put(so.getRegionId(), quantity);
    }
   
    

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:InitialLoadEntityManagerProxy.java

示例14: findTodayTasks

import java.util.Calendar; //导入方法依赖的package包/类
public List<PimTask> findTodayTasks(String userId) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    Date startTime = calendar.getTime();
    calendar.add(Calendar.DATE, 1);

    Date endTime = calendar.getTime();
    String hql = "from PimTask where userId=? and startTime between ? and ? order by priority";

    return pimTaskManager.find(hql, userId, startTime, endTime);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:16,代码来源:PimTaskController.java

示例15: getTomorrowDate

import java.util.Calendar; //导入方法依赖的package包/类
public static Date getTomorrowDate(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.add(Calendar.DATE, 1);
    return cal.getTime();
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:7,代码来源:DateHelper.java


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