當前位置: 首頁>>代碼示例>>Java>>正文


Java Date類代碼示例

本文整理匯總了Java中java.util.Date的典型用法代碼示例。如果您正苦於以下問題:Java Date類的具體用法?Java Date怎麽用?Java Date使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Date類屬於java.util包,在下文中一共展示了Date類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transformReleaseHistoryDTO2BO

import java.util.Date; //導入依賴的package包/類
private ReleaseHistoryBO transformReleaseHistoryDTO2BO(ReleaseHistoryDTO dto, ReleaseDTO release){
  ReleaseHistoryBO bo = new ReleaseHistoryBO();
  bo.setId(dto.getId());
  bo.setAppId(dto.getAppId());
  bo.setClusterName(dto.getClusterName());
  bo.setNamespaceName(dto.getNamespaceName());
  bo.setBranchName(dto.getBranchName());
  bo.setReleaseId(dto.getReleaseId());
  bo.setPreviousReleaseId(dto.getPreviousReleaseId());
  bo.setOperator(dto.getDataChangeCreatedBy());
  bo.setOperation(dto.getOperation());
  Date releaseTime = dto.getDataChangeLastModifiedTime();
  bo.setReleaseTime(releaseTime);
  bo.setReleaseTimeFormatted(RelativeDateFormat.format(releaseTime));
  bo.setOperationContext(dto.getOperationContext());
  //set release info
  setReleaseInfoToReleaseHistoryBO(bo, release);

  return bo;
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:21,代碼來源:ReleaseHistoryService.java

示例2: updateLastMobileAccessTime

import java.util.Date; //導入依賴的package包/類
/**
 * update the lastmobileAccess time
 *
 * @param userId user id
 * @param aTime  accessed time
 */
@Override
public boolean updateLastMobileAccessTime(String userId, long aTime) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  IUserAccount userAccount;
  Date now = new Date(aTime);
  try {
    userAccount = JDOUtils.getObjectById(IUserAccount.class, userId, pm);
    if (userAccount.getLastMobileAccessed() == null
        || userAccount.getLastMobileAccessed().compareTo(now) < 0) {
      userAccount.setLastMobileAccessed(now);
    }
  } catch (Exception e) {
    xLogger
        .warn("{0} while updating last transacted time for the user, {1}", e.getMessage(), userId,
            e);
    return false;
  } finally {
    pm.close();
  }
  return true;
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:28,代碼來源:UsersServiceImpl.java

示例3: doAfterReturning

import java.util.Date; //導入依賴的package包/類
@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) {
    // 處理完請求,返回內容
    WebOosLog commLogger = commLoggerThreadLocal.get();
    commLogger.setActionResCode(ResponseStatus.SUCCESS);
    commLogger.setReqEndTime(new Date());
    commLogger.setReqDealTime((int) (commLogger.getReqEndTime().getTime() - commLogger.getReqStartTime().getTime()));
    commLogger.setResponseData(JSON.toJSONString(ret));
    commLogger.setIsUndefinedException(false);

    loggerRecordService.doRecord(commLogger);

    logger.debug("RESPONSE : " + JSON.toJSONString(ret));
    logger.debug("SPEND TIME : " + commLogger.getReqDealTime() + "ms");
    logger.debug("***************請求" + commLogger.getActionDesc() + "結束***************");
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:17,代碼來源:WebLogAspect.java

示例4: createGraph

import java.util.Date; //導入依賴的package包/類
private void createGraph() {
    _graphView.removeAllSeries();

    SerializableList<MoneyMeterData> moneyMeterDataList = MoneyMeterListService.getInstance().GetActiveMoneyMeter().GetMoneyMeterDataList();
    int moneyMeterDataListSize = moneyMeterDataList.getSize();
    DataPoint[] dataPoints = new DataPoint[moneyMeterDataListSize];

    Date firstDate = new Date();
    Date lastDate = new Date();

    for (int index = 0; index < moneyMeterDataListSize; index++) {
        SerializableDate saveDate = moneyMeterDataList.getValue(index).GetSaveDate();
        Date date = new Date(saveDate.Year(), saveDate.Month() - 1, saveDate.DayOfMonth());
        dataPoints[index] = new DataPoint(date, moneyMeterDataList.getValue(index).GetAmount());
        if (index == 0) {
            firstDate = date;
        } else if (index == moneyMeterDataListSize - 1) {
            lastDate = date;
        }
    }

    LineGraphSeries<DataPoint> series = new LineGraphSeries<>(dataPoints);
    _graphView.addSeries(series);

    _graphView.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(this));
    _graphView.getGridLabelRenderer().setNumHorizontalLabels(3);

    _graphView.getViewport().setMinX(firstDate.getTime());
    _graphView.getViewport().setMaxX(lastDate.getTime());
    _graphView.getViewport().setXAxisBoundsManual(true);

    _graphView.getGridLabelRenderer().setHumanRounding(false);
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:34,代碼來源:MoneyMeterDataActivity.java

示例5: startInternal

import java.util.Date; //導入依賴的package包/類
/**
 * Start this component and implement the requirements of
 * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException
 *                if this component detects a fatal error that prevents this
 *                component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

	// Initialize the Date formatters
	String format = getFileDateFormat();
	fileDateFormatter = new SimpleDateFormat(format, Locale.US);
	fileDateFormatter.setTimeZone(TimeZone.getDefault());
	dateStamp = fileDateFormatter.format(new Date(System.currentTimeMillis()));
	if (rotatable && renameOnRotate) {
		restore();
	}
	open();

	setState(LifecycleState.STARTING);
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:24,代碼來源:AccessLogValve.java

示例6: newResponse

import java.util.Date; //導入依賴的package包/類
/**
 * Create a new response object.
 * 
 * @param cls
 * 
 * @return The object.
 */
private <T extends MwsObject> T newResponse(
        Class<T> cls) {
    InputStream is = null;
    try {
        is = this.getClass().getResourceAsStream(cls.getSimpleName()+".xml");
        MwsXmlReader reader = new MwsXmlReader(is);
        T obj = cls.newInstance();
        obj.readFragmentFrom(reader);
        ResponseHeaderMetadata rhmd = new ResponseHeaderMetadata(
            "mockRequestId", Arrays.asList("A","B","C"), "mockTimestamp", 0d, 0d, new Date());
        cls.getMethod("setResponseHeaderMetadata", rhmd.getClass()).invoke(obj,  rhmd);
        return obj;
    } catch (Exception e) {
        throw MwsUtl.wrap(e);
    } finally {
        MwsUtl.close(is);
    }
}
 
開發者ID:trifonnt,項目名稱:ext-lib-amazon-mws-fulfillment-inbound-shipment,代碼行數:26,代碼來源:FBAInboundServiceMWSMock.java

示例7: savePlayer

import java.util.Date; //導入依賴的package包/類
public void savePlayer(@RequestBody player play){

        Random rand = new Random();
        int value = rand.nextInt(99);
        int value2 = rand.nextInt(99);

        String identityNumber = "TheLXG-Phy"+value+"1"+value2+"-"+play.getAlias();
        play.setPlayerId(identityNumber);
//        eMail.setMessageForPlayer(play);/*sets player Object mail is sent to and embeds details to message.*/
        Date date = new Date();
        play.setDate(date);
        playerService.addPlayer(play);

        if(sendMailNotification.sendEmail(play, eMail,"The LXG - Registration")){
            play.setMailStatus("mail sent");
        }else{
            play.setMailStatus("mail not sent");
        }

        playerService.updatePlayer(play);

    }
 
開發者ID:Recks11,項目名稱:theLXGweb,代碼行數:23,代碼來源:SavePlayerAndSendMailImpl.java

示例8: putItemInData

import java.util.Date; //導入依賴的package包/類
public void putItemInData(double money) {
    Sum sum = new Sum();
    IOItem ioItem = new IOItem();
    String tagName = (String) bannerText.getTag();
    int tagType = (int) bannerImage.getTag();

    if (tagType < 0) {
        ioItem.setType(ioItem.TYPE_COST);
    } else ioItem.setType(ioItem.TYPE_EARN);

    ioItem.setName(bannerText.getText().toString());
    ioItem.setSrcName(tagName);
    ioItem.setMoney(money);
    ioItem.setTimeStamp(formatItem.format(new Date()));         // 存儲記賬時間
    ioItem.setDescription(GlobalVariables.getmDescription());
    ioItem.save();

    // 存儲完之後及時清空備注
    GlobalVariables.setmDescription("");

    int type = ioItem.getType();
    String sumDate = formatSum.format(new Date());
    // 計算總額
    sum.calculateMoneyIncludeNull(sum.SUM, "All", money, type, sumDate);
    calculateMonthlyMoney(type, ioItem);
}
 
開發者ID:yuukidach,項目名稱:Ucount,代碼行數:27,代碼來源:AddItemActivity.java

示例9: getCurrentTimerExpirationDates

import java.util.Date; //導入依賴的package包/類
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<VOTimerInfo> getCurrentTimerExpirationDates() {
    List<VOTimerInfo> result = new ArrayList<VOTimerInfo>();

    for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService()
            .getTimers(), Timer.class)) {
        Serializable info = timer.getInfo();
        if (info != null && info instanceof TimerType) {
            TimerType type = (TimerType) info;
            long expirationTime = timer.getTimeRemaining()
                    + System.currentTimeMillis();
            VOTimerInfo timerInfo = new VOTimerInfo();
            timerInfo.setTimerType(type.name());
            timerInfo.setExpirationDate(new Date(expirationTime));
            result.add(timerInfo);
        }
    }

    return result;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:21,代碼來源:TimerServiceBean.java

示例10: sendEmail

import java.util.Date; //導入依賴的package包/類
private static void sendEmail(String emailSubject, String emailBody) {
  logger.info("About to notify DEV and QA teams...");
  String body = String.format(EMAIL_TMPL_HEADER,
      new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z").format(new Date()))
      + emailBody;
  String emailTempFileContent = String.format(
      EMAIL_TMPL_CONTENT,
      PropertiesUtil.getString("email.sender"),
      emailSubject,
      body);
  try {
    String sendMailCommand = String.format(
        EMAIL_TMPL_CMD,
        emailTempFileContent,
        PropertiesUtil.getString("email.to.notify")
    );
    CommandExecutor.run( sendMailCommand, null);

  } catch (Exception e) {
    logger.error("Email notification has failed", e);
  }
}
 
開發者ID:lpavone,項目名稱:SVNAutoMerger,代碼行數:23,代碼來源:Notifier.java

示例11: queryGlucoseBetween

import java.util.Date; //導入依賴的package包/類
/**
 * This method is used to query {@link VaultEntry}s which are of a given type and lie in a specified period.
 * The types to be queried for are glucose types:
 * <ul>
 *     <li>{@link VaultEntryType#GLUCOSE_BG}</li>
 *     <li>{@link VaultEntryType#GLUCOSE_CGM}</li>
 *     <li>{@link VaultEntryType#GLUCOSE_CGM_ALERT}</li>
 * </ul>
 *
 * @param from The start of the period to query entries from.
 * @param to The end of the period to query entries from.
 * @return All {@link VaultEntry} which are of the required type and lie in the specified period.
 */
//TODO OTHER TYPES? Let's ask Jens @next meeting
public List<VaultEntry> queryGlucoseBetween(final Date from, final Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_BG)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_CGM)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_CGM_ALERT)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValues;
}
 
開發者ID:lucasbuschlinger,項目名稱:BachelorPraktikum,代碼行數:35,代碼來源:VaultDao.java

示例12: populateTestRealm

import java.util.Date; //導入依賴的package包/類
private void populateTestRealm(Realm testRealm, int objects) {
    testRealm.beginTransaction();
    testRealm.deleteAll();
    for (int i = 0; i < objects; i++) {
        AllTypes allTypes = testRealm.createObject(AllTypes.class);
        allTypes.setColumnBoolean((i % 3) == 0);
        allTypes.setColumnBinary(new byte[]{1, 2, 3});
        allTypes.setColumnDate(new Date(DECADE_MILLIS * (i - (objects / 2))));
        allTypes.setColumnDouble(Math.PI);
        allTypes.setColumnFloat(1.234567f + i);
        allTypes.setColumnString("test data " + i);
        allTypes.setColumnLong(i);
        NonLatinFieldNames nonLatinFieldNames = testRealm.createObject(NonLatinFieldNames.class);
        nonLatinFieldNames.set델타(i);
        nonLatinFieldNames.setΔέλτα(i);
        nonLatinFieldNames.set베타(1.234567f + i);
        nonLatinFieldNames.setΒήτα(1.234567f + i);
    }
    testRealm.commitTransaction();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RealmResultsTests.java

示例13: ZhihuDailyDateFormat

import java.util.Date; //導入依賴的package包/類
/**
 * 將long類date轉換為String類型
 * @param date date
 * @return String date
 */
public String ZhihuDailyDateFormat(long date) {
    String sDate;
    Date d = new Date(date + 24*60*60*1000);
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
    sDate = format.format(d);

    return sDate;
}
 
開發者ID:makezhao,項目名稱:LianXiZhihu,代碼行數:14,代碼來源:DateFormatter.java

示例14: createSyndEntry

import java.util.Date; //導入依賴的package包/類
protected SyndEntry createSyndEntry(Item item) {
    SyndEntry syndEntry = super.createSyndEntry(item);
    Date pubDate = item.getPubDate();
    if (pubDate!=null) {
        syndEntry.setPublishedDate(pubDate);     //c
    }
    return syndEntry;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:9,代碼來源:ConverterForRSS093.java

示例15: testDateSet

import java.util.Date; //導入依賴的package包/類
@Test
public void testDateSet() {
    assertEquals(Collections.singletonList("1970-01-01T00:00:00Z"),
                 convert("getDateSet", Collections.singleton(new Date(0)))
                         .ss());

    Calendar c = GregorianCalendar.getInstance();
    c.setTimeInMillis(0);

    assertEquals(Collections.singletonList("1970-01-01T00:00:00Z"),
                 convert("getCalendarSet", Collections.singleton(c))
                         .ss());
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:14,代碼來源:StandardModelFactoriesV2Test.java


注:本文中的java.util.Date類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。