List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:com.clustercontrol.repository.session.RepositoryControllerBean.java
/** * ???//from w w w . j a v a2s .c o m * * @return */ public Date getLastUpdate() { Date updateTime = new Date(SettingUpdateInfo.getInstance().getRepositoryUpdateTime()); m_log.debug("getLastUpdate() lastUpdate = " + updateTime.toString()); return updateTime; }
From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertCategoryAxisTreeDTO.java
@Transactional(rollbackFor = Exception.class) public int convertCategoryTree(Date date, ADSMSchedulerLogDTO schedulerLog, String treeName, ADSMJobNameType srcJopType, boolean isPartialUpdate, ADSMSchedulerLogDTO deleteSchedulerLog, Platform platformType) throws Exception { if (schedulerLog == null) { throw new CiRuntimeException("ADSMSchedulerLog is null"); }//from w w w. j a v a2s .c o m if (treeName == null || treeName.isEmpty()) { throw new CiRuntimeException("Cannot find treeName in generating CategoryTree"); } long start = System.currentTimeMillis(); this.srcJobType = srcJopType; log.info("TreeName : " + treeName + ", srcDataType : " + srcJopType + ". Start Update(" + schedulerLog.getParam() + ")"); int treeID = 0; int dataLogID = Integer.parseInt((String) schedulerLog.getParamValue("dataLogId")); String licenseStartDateStr = null; List<CategoryDTO> invenBoxCategoryDTOs = null; List<VirtualCategoryDTO> virtualCategoryDTOs = null; String addsSite = null; if (ADSMJobNameType.INVENTORY_CATEGORY_DATA == srcJopType || ADSMJobNameType.CATEGORY_DATA == srcJopType) { licenseStartDateStr = (String) schedulerLog.getParamValue(FilePolling.PARAM_START_TIME_PREFIX); addsSite = (String) schedulerLog.getParamValue(FilePolling.PARAM_SITE_PREFIX); invenBoxCategoryDTOs = tambourineConnector.getCategoryListFromInventoryBox(date); VirtualCategoryDefineDTO virtualCategoryDefineDTO = tambourineConnector .getVirtualCategoryDefineList(date); if (virtualCategoryDefineDTO != null) virtualCategoryDTOs = virtualCategoryDefineDTO.getVirtualCategoryList(); if (invenBoxCategoryDTOs == null || invenBoxCategoryDTOs.size() == 0) log.warn("Cannot find InventoryBox at " + date.toString()); } try { //?, , , ? //tambourineConnector.initializeInventoryCube(date); NodeDTO rootNodeDTO = getRootNode(dataLogID); if (rootNodeDTO == null) { throw new CiRuntimeException("Fail to Update Category Tree (Cannot Check root node Info. " + schedulerLog.getParam() + ")"); } treeID = tambourineConnector.getAxisTreeId(TreeType.CATEGORY_AXIS_TREE, treeName, addsSite, platformType, false); //? if (treeID <= 0) treeID = tambourineConnector.registerCategoryAxisTree( getAxisTreeDTO(treeName, rootNodeDTO, addsSite, platformType), date); //TreeNode . //? if (ADSMJobNameType.INVENTORY_CATEGORY_DATA == srcJopType || ADSMJobNameType.CATEGORY_DATA == srcJopType) { if (licenseStartDateStr != null) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date licenseStartDate = sdf.parse(licenseStartDateStr); Date syncStartDate = licenseStartDate; Date nowDate = new Date(); if (isPartialUpdate == false) syncStartDate = nowDate; makeTreeNode(treeID, licenseStartDate, rootNodeDTO.getExternalNodeId(), invenBoxCategoryDTOs, virtualCategoryDTOs, dataLogID, isPartialUpdate); String param = "treeId:" + treeID + "/treeType:" + TreeType.CATEGORY_AXIS_TREE.toString() + "/treeName:" + treeName; FeSyncNoticeboardDTO feSyncNoticeboardDTO = tambourineConnector.generateFeSyncNoticeboardData( SyncDataType.TREEDATA, syncStartDate, param, addsSite, FeSyncNoticeboardStatus.NEWDATA, platformType, null, null); //? sync ,treetype,treeName? syncNoticeboard disable tambourineConnector.disableFeSyncNoticeboard(feSyncNoticeboardDTO); // syncNoticeboard? ? if (isPartialUpdate == false) tambourineConnector.insertTreeLogNSyncNoticeboard(treeID, TreeType.CATEGORY_AXIS_TREE, treeName, feSyncNoticeboardDTO, addsSite, platformType); } else { makeTreeNode(treeID, date, rootNodeDTO.getExternalNodeId(), invenBoxCategoryDTOs, virtualCategoryDTOs, dataLogID, isPartialUpdate); addsSite = ADDSAdapterSetting.defaultSiteName; insertTreeLogNSyncNoticeboard(addsSite, treeID, treeName, null); } // ? ?? ? ? ? ?? ? ?? . if (isPartialUpdate == false) { if (deleteSchedulerLog == null) throw new CiRuntimeException("Cannot Find deleteSchedulerLog in generating CategoryTree."); if (updateDisableContentPolicy(treeID, deleteSchedulerLog.getId()) == true) { deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); } else deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.DONE); } } else { //viettel STB, OTT ? makeTreeNode(treeID, date, rootNodeDTO.getExternalNodeId(), null, null, dataLogID, false); Platform platform = getPlatformTypeByADSMJobNameType(srcJopType); insertTreeLogNSyncNoticeboard(addsSite, treeID, treeName, platform); } // ? schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); schedulerLog.setMessage(TREE_NAME_MESSAGE_PREFIX + treeName); } catch (Exception e) { long end = System.currentTimeMillis(); TheLogger.getWriter().error("Fail to Update Category Tree"); log.error("Fail to update Category Tree.(" + schedulerLog.getParam() + ") - T(" + (end - start) + ")"); schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); if (ADSMJobNameType.INVENTORY_CATEGORY_DATA == srcJopType || ADSMJobNameType.CATEGORY_DATA == srcJopType) { deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); } StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { schedulerLog.setFailProcess(stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"); } throw e; } long end = System.currentTimeMillis(); log.info("Complete to Update Category Tree (" + schedulerLog.getParam() + ") - T(" + (end - start) + ")"); TheLogger.getWriter().info("Complete to Update Category Tree(" + schedulerLog.getParam() + ")"); return treeID; }
From source file:com.dell.asm.asmcore.asmmanager.app.AsmManagerApp.java
private void createDefaultRazorSyncJob() { _logger.info("Create Default Razor Sync job."); IJobManager jobMgr = JobManager.getInstance(); try {/* w w w. j ava 2 s. c om*/ CronScheduleBuilder schedBuilder = CronScheduleBuilder.cronSchedule(razorCron); Set<JobKey> jobKeySet = jobMgr.getScheduler() .getJobKeys(GroupMatcher.jobGroupEquals(RazorSyncJob.class.getSimpleName())); JobDetail jobDetail = null; Date nextRun; if ((jobKeySet == null) || jobKeySet.isEmpty()) { _logger.info("Razor sync Job is not present."); jobDetail = jobMgr.createNamedJob(RazorSyncJob.class, DEFAULT_RAZOR_SYNC_JOB_NAME, null, DEFAULT_RAZOR_SYNC_JOB_DESC); Trigger trigger = jobMgr.createNamedTrigger(schedBuilder, jobDetail, false); nextRun = jobMgr.scheduleJob(jobDetail, trigger); } else { _logger.info("Razor sync Job is already present."); for (JobKey jobKey : jobKeySet) { _logger.info("Found Job Key " + jobKey.getName()); jobDetail = jobMgr.getJobDetail(jobKey); } Trigger trigger = jobMgr.createNamedTrigger(schedBuilder, jobDetail, false); nextRun = jobMgr.rescheduleJob(DEFAULT_RAZOR_SYNC_JOB_NAME, trigger); } _logger.info("next run scheduled at: " + nextRun.toString()); //System.out.println("next run scheduled at: " + nextRun.toString()); if (!jobMgr.getScheduler().isStarted()) { jobMgr.getScheduler().start(); _logger.info("scheduler started"); } } catch (Exception e) { String msg = "Failed to schedule razor sync job: " + e.getMessage(); _logger.error(msg, e); } }
From source file:mesquite.lib.MesquiteModule.java
/** Returns the name of the duty; set by the duty-defining library classes.*/ public String getDateAndTime() { long time = System.currentTimeMillis(); Date dnow = new Date(time); return dnow.toString(); }
From source file:org.nuclos.server.ruleengine.ejb3.RuleInterfaceFacadeBean.java
/** * performs a state change for the leased object with the given id at the given point in time. If an old job exists already, it * is always removed.//ww w .j a va2 s. c o m * @param iGenericObjectId * @param iNewState the new state for the object. * @param dateToSchedule the date for the state change to happen. If <code>null</code> only a possibly existing job is removed. * If <code>dateToSchedule</code> is in the future, a new job is scheduled for the given date. If <code>dateToSchedule</code> is in the past, * the state change is executed immediately (synchronously). * @precondition iGenericObjectId != null * @throws NuclosBusinessRuleException if the transition from the current state to the new state is not possible for the given object. */ public GenericObjectVO scheduleStateChange(GenericObjectVO govoCurrent, Integer iGenericObjectId, int iNewState, Date dateToSchedule, String customUsage) throws NuclosBusinessRuleException, CommonFinderException { if (iGenericObjectId == null) { throw new NuclosFatalRuleException( "scheduleStateChangeJob(Integer iGenericObjectId, int iNewState, Date dateToSchedule): iGenericObjectId darf nicht null sein."); } if (!this.isStateChangePossible(iGenericObjectId, iNewState)) { throw new NuclosBusinessRuleException( StringUtils.getParameterizedExceptionMessage("state.transition.error", iNewState)); //"Der Status\u00fcbergang nach " + iNewState + " ist nicht m\u00f6glich."); } GenericObjectVO result = govoCurrent; try { final String sJobName = "InnerStateChangeJob for GenericObjectId " + iGenericObjectId + " and target state " + iNewState; // Always delete a possibly existing old job: if (nuclosScheduler.deleteJob(sJobName, Scheduler.DEFAULT_GROUP)) { info("Removed " + sJobName + "."); } if (dateToSchedule != null) { if (dateToSchedule.before(new Date())) { // execute state change immediately: result = this.changeState(govoCurrent, iGenericObjectId, iNewState, customUsage); } else { final JobDetail jobDetail = new JobDetail(sJobName, Scheduler.DEFAULT_GROUP, StateChangeJob.class); jobDetail.getJobDataMap().put(StateChangeJob.PARAM_LEASEDOBJECTID, iGenericObjectId.intValue()); jobDetail.getJobDataMap().put(StateChangeJob.PARAM_NEWSTATE, iNewState); nuclosScheduler.scheduleJob(jobDetail, new SimpleTrigger(sJobName, Scheduler.DEFAULT_GROUP, dateToSchedule)); info("Successfully scheduled " + sJobName + " at " + dateToSchedule.toString() + "."); } } } catch (SchedulerException ex) { throw new NuclosFatalException(ex); } return result; }
From source file:org.opendatakit.aggregate.odktables.DataManager.java
/** * Perform direct query on dateColToUseForCompare to retrieve the * SEQUENCE_VALUE of that row. This is then used to construct the * query for getting data with that using this start time. * /*from www . j a v a 2 s . co m*/ * @param logTable - the log table to use * @param dateColToUseForCompare - the date field to use for the comparison * @param givenTimestamp - the original string value the user passed in * @param dateToCompare - the date to compare against the LAST_UPDATE_DATE_COLUMN_NAME * @param dir - the sort direction to use when retrieving the data * @return SEQUENCE_VALUE of that row * @throws ODKDatastoreException */ private String getSequenceValueForStartTime(DbLogTable logTable, String dateColToUseForCompare, String givenTimestamp, Date dateToCompare, Direction dir) throws ODKDatastoreException { Query query = logTable.query("DataManager.getSequenceValueForTimestamp", cc); // we need the filter to activate the sort for the sequence value query.addFilter(DbLogTable.SEQUENCE_VALUE, org.opendatakit.common.persistence.Query.FilterOperation.GREATER_THAN, " "); query.addSort(DbLogTable.SEQUENCE_VALUE, dir); // _LAST_UPDATE_DATE is a datetime field // _SAVEPOINT_TIMESTAMP is a String field if (dateColToUseForCompare.equals(DbLogTable.LAST_UPDATE_DATE_COLUMN_NAME)) { query.addFilter(dateColToUseForCompare, org.opendatakit.common.persistence.Query.FilterOperation.GREATER_THAN_OR_EQUAL, dateToCompare); } else if (dateColToUseForCompare.equals(DbLogTable.SAVEPOINT_TIMESTAMP.getName())) { query.addFilter(dateColToUseForCompare, org.opendatakit.common.persistence.Query.FilterOperation.GREATER_THAN_OR_EQUAL, givenTimestamp); } List<Entity> values = query.execute(); if (values == null || values.size() == 0) { throw new ODKEntityNotFoundException( "Timestamp " + dateToCompare.toString() + " was not found in log table!"); } Entity e = values.get(0); return e.getString(DbLogTable.SEQUENCE_VALUE); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
@Subscribe public void updateTime(final AjaxRequestTarget target, final Date event) { target.prependJavaScript(/*ww w. j ava 2s . co m*/ "if (document.activeElement.tagName !== 'INPUT') { var chatPos = document.getElementById('chat').scrollTop; document.getElementById('clockLabel').innerHTML = '" + event.toString() + "'; document.getElementById('chat').scrollTop = chatPos; }"); }
From source file:org.getobjects.eoaccess.EOSQLExpression.java
/** * The current implementation just returns the 'toString()' of the Date * (which is rarely the correct thing to do). * You should really use bindings for that. * /*from w w w. j a va 2 s . co m*/ * @param _v - a Date object * @param _attr - an EOAttribute containing formatting details * @return the SQL representation of the given Date (or NULL for null) */ public String formatDateValue(final Date _v, final EOAttribute _attr) { // TODO: fixme. Use format specifications as denoted in the attribute // TODO: is this called? Probably the formatting should be done using a // binding in the JDBC adaptor if (log.isWarnEnabled()) log.warn("rendering a Date in SQL as a (Java formatted) String: " + this); if (_v == null) return null; return this.formatStringValue(_v.toString()); }
From source file:com.dell.asm.asmcore.asmmanager.app.AsmManagerApp.java
private void createDefaultScheduledInventoryJob() { _logger.info("Create Default Scheduled Inventory job."); IJobManager jobMgr = JobManager.getInstance(); try {//w w w. j a v a 2 s .c o m CronScheduleBuilder schedBuilder = CronScheduleBuilder.cronSchedule(scheduledInventoryCron); Set<JobKey> jobKeySet = jobMgr.getScheduler() .getJobKeys(GroupMatcher.jobGroupEquals(ScheduledInventoryJob.class.getSimpleName())); JobDetail jobDetail = null; Date nextRun; if ((jobKeySet == null) || jobKeySet.isEmpty()) { jobDetail = jobMgr.createNamedJob(ScheduledInventoryJob.class, RECURRING_CHECK_SCHEDULEDINVENTORY_JOB_KEY_NAME, null, RECURRING_CHECK_SCHEDULEDINVENTORY_JOB_KEY_DESC); Trigger trigger = jobMgr.createNamedTrigger(schedBuilder, jobDetail, false); nextRun = jobMgr.scheduleJob(jobDetail, trigger); } else { _logger.info("ScheduledInventory job is already present."); for (JobKey jobKey : jobKeySet) { _logger.info("Found Job Key " + jobKey.getName()); if (RECURRING_CHECK_SCHEDULEDINVENTORY_JOB_KEY_NAME.equals(jobKey.getName())) { jobDetail = jobMgr.getJobDetail(jobKey); } } Trigger trigger = jobMgr.createNamedTrigger(schedBuilder, jobDetail, false); nextRun = jobMgr.rescheduleJob(RECURRING_CHECK_SCHEDULEDINVENTORY_JOB_KEY_NAME, trigger); } _logger.info("next run scheduled at: " + nextRun.toString()); if (!jobMgr.getScheduler().isStarted()) { jobMgr.getScheduler().start(); _logger.info("scheduler started"); } } catch (Exception e) { String msg = "Failed to schedule recurring inventory job: " + e.getMessage(); _logger.error(msg, e); } }
From source file:org.opendatakit.odktables.DataManager.java
/** * Perform direct query on dateColToUseForCompare to retrieve the * SEQUENCE_VALUE of that row. This is then used to construct the query for * getting data with that using this end time. * //from w ww . j a v a 2 s . c o m * @param logTable * - the log table to use * @param dateColToUseForCompare * - the date field to use for the comparison * @param givenTimestamp * - the original string value the user passed in * @param dateToCompare * - the date to compare against the LAST_UPDATE_DATE_COLUMN_NAME * @param dir * - the sort direction to use when retrieving the data * @return SEQUENCE_VALUE of that row * @throws ODKDatastoreException */ private String getSequenceValueForEndTime(DbLogTable logTable, String dateColToUseForCompare, String givenTimestamp, Date dateToCompare, Direction dir) throws ODKDatastoreException { Query query = logTable.query("DataManager.getSequenceValueForTimestamp", cc); // we need the filter to activate the sort for the sequence value query.addFilter(DbLogTable.SEQUENCE_VALUE, org.opendatakit.persistence.Query.FilterOperation.GREATER_THAN, " "); query.addSort(DbLogTable.SEQUENCE_VALUE, dir); // _LAST_UPDATE_DATE is a datetime field // _SAVEPOINT_TIMESTAMP is a String field if (dateColToUseForCompare.equals(DbLogTable.LAST_UPDATE_DATE_COLUMN_NAME)) { query.addFilter(dateColToUseForCompare, org.opendatakit.persistence.Query.FilterOperation.LESS_THAN_OR_EQUAL, dateToCompare); } else if (dateColToUseForCompare.equals(DbLogTable.SAVEPOINT_TIMESTAMP.getName())) { query.addFilter(dateColToUseForCompare, org.opendatakit.persistence.Query.FilterOperation.LESS_THAN_OR_EQUAL, givenTimestamp); } List<Entity> values = query.execute(); if (values == null || values.size() == 0) { throw new ODKEntityNotFoundException( "Timestamp " + dateToCompare.toString() + " was not found in log table!"); } Entity e = values.get(0); return e.getString(DbLogTable.SEQUENCE_VALUE); }