List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:fr.juanwolf.mysqlbinlogreplicator.component.DomainClassAnalyzer.java
public void instantiateField(Object object, Field field, Object value, int columnType, String tablename) throws ParseException, IllegalAccessException { field.setAccessible(true);//from w w w . jav a 2 s.co m if (columnType == ColumnType.DATETIME.getCode() && field.getType() == Date.class) { Date date = BINLOG_DATETIME_FORMATTER.parse((String) value); field.set(object, date); } else if (columnType == ColumnType.DATE.getCode() && field.getType() == Date.class) { Date date = BINLOG_DATE_FORMATTER.parse((String) value); field.set(object, date); } else if (columnType == ColumnType.DATETIME.getCode() && field.getType() == String.class) { Date date = BINLOG_DATETIME_FORMATTER.parse((String) value); if (binlogOutputDateFormatter != null) { field.set(object, binlogOutputDateFormatter.format(date)); } else { log.warn("No date.output DateFormat found in your property file. If you want anything else than" + "the timestamp as output of your date, set this property with a java DateFormat."); field.set(object, date.toString()); } } else if (columnType == ColumnType.TIME.getCode() && field.getType() == Time.class) { Time time = Time.valueOf((String) value); field.set(object, time); } else if (columnType == ColumnType.TIMESTAMP.getCode() || field.getType() == Timestamp.class) { Timestamp timestamp = Timestamp.valueOf((String) value); field.set(object, timestamp); } else if ((columnType == ColumnType.BIT.getCode() || columnType == ColumnType.TINY.getCode()) && field.getType() == boolean.class) { boolean booleanField = ((Byte) value) != 0; field.set(object, booleanField); } else if (columnType == ColumnType.LONG.getCode() && field.getType() == long.class) { field.set(object, Long.parseLong((String) value)); } else if (columnType == ColumnType.LONG.getCode() && isInteger(field)) { field.set(object, Integer.parseInt((String) value)); } else if (columnType == ColumnType.FLOAT.getCode() && field.getType() == float.class) { field.set(object, Float.parseFloat((String) value)); } else if (field.getType() == String.class) { field.set(object, value); } else { if (mappingTablesExpected.contains(tablename)) { Object nestedObject = generateNestedField(field, value, tablename); field.set(object, nestedObject); } } }
From source file:org.kuali.ole.docstore.process.RebuildIndexesHandler.java
private void reIndex(String docCategory, String docType, String docFormat) { Session session = null;// w w w .j a v a 2 s . com setRunning(true); logger.info("Rebuild Indexes Run(" + docCategory + " : " + docType + " : " + docFormat + "): "); try { if (docCategory.equals(DocCategory.WORK.getCode())) { if (docType.equals(DocType.BIB.getDescription())) { if (docFormat.equals(DocFormat.MARC.getCode()) || docFormat.equals(DocFormat.DUBLIN_CORE.getCode()) || docFormat.equals(DocFormat.DUBLIN_UNQUALIFIED.getCode())) { org.springframework.util.StopWatch stopWatch = new org.springframework.util.StopWatch(); stopWatch.start("total time taken"); Date date = new Date(); EXCEPION_FILE_NAME = "ReindexErrors-" + date.toString() + ".txt"; STATUS_FILE_NAME = "ReindexBatchStatus-" + date.toString() + ".txt"; BatchBibTreeDBUtil.writeStatusToFile(filePath, RebuildIndexesHandler.EXCEPION_FILE_NAME, "Reindex started at:" + date); BibHoldingItemReindexer bibHoldingItemReindexer = BibHoldingItemReindexer.getInstance(); bibHoldingItemReindexer.setTotalBatchStatistics(new ReindexBatchStatistics()); bibHoldingItemReindexer.index(batchSize, startIndex, endIndex, updateDate); date = new Date(); BatchBibTreeDBUtil.writeStatusToFile(filePath, RebuildIndexesHandler.EXCEPION_FILE_NAME, "Reindex ended at:" + date); stopWatch.stop(); logger.info(stopWatch.prettyPrint()); // workBibMarcAndDublinAll(docCategory, docType, docFormat); } else { logger.info("Rebuild Indexes Run(" + docCategory + " : " + docType + " : " + docFormat + "): FAIL"); } } else if (docType.equals(DocType.INSTANCE.getDescription())) { if (docFormat.equals(DocFormat.OLEML.getCode())) { workInstanceOLEML(docCategory, docType, docFormat); } else { logger.info("Rebuild Indexes Run(" + docCategory + " : " + docType + " : " + docFormat + "): FAIL"); } } else if (docType.equals(DocType.LICENSE.getDescription())) { if (docFormat.equals(DocFormat.ONIXPL.getCode()) || docFormat.equals(DocFormat.PDF.getCode()) || docFormat.equals(DocFormat.DOC.getCode())) { workLicense(docCategory, docType, docFormat); } else { logger.info("Rebuild Indexes Run(" + docCategory + " : " + docType + " : " + docFormat + "): FAIL"); } } else if (docType.equals(DocType.EINSTANCE.getCode())) { if (docFormat.equals(DocFormat.OLEML.getCode())) { workEInstanceOLEML(docCategory, docType, docFormat); } else { logger.info("Rebuild Indexes Run(" + docCategory + " : " + docType + " : " + docFormat + "): FAIL"); } } } } catch (Exception e) { logger.info(e.getMessage(), e); } finally { try { if (isStop) { ReIndexingStatus.getInstance().getDocTypeList().setStatus("Stopped"); } else { ReIndexingStatus.getInstance().getDocTypeList().setStatus("Done"); } RepositoryManager.getRepositoryManager().logout(session); } catch (OleException e) { logger.error(e.getMessage(), e); } } }
From source file:dk.dma.ais.packet.AisPacketKMLOutputSink.java
protected Kml createKml() throws IOException { Kml kml = new Kml(); Document document = kml.createAndSetDocument().withOpen(true); String docDesc = description.get(); if (!isBlank(docDesc)) { document.withDescription(docDesc); }/* w w w.jav a 2 s . c om*/ String docTitle = title.get(); if (!isBlank(docTitle)) { document.withName(docTitle); } Camera camera = document.createAndSetCamera().withAltitude(2000).withHeading(0).withTilt(0) .withAltitudeMode(AltitudeMode.ABSOLUTE); if (scenarioTracker.boundingBox() != null) { camera.withLatitude( (scenarioTracker.boundingBox().getMaxLat() + scenarioTracker.boundingBox().getMinLat()) / 2.0) .withLongitude( (scenarioTracker.boundingBox().getMaxLon() + scenarioTracker.boundingBox().getMinLon()) / 2.0); } // Create all ship styles createKmlStyles(document); Folder rootFolder = document.createAndAddFolder().withName("Vessel scenario").withOpen(true) .withVisibility(true); StringBuffer rootFolderName = new StringBuffer(); Date scenarioBegin = scenarioTracker.scenarioBegin(); Date scenarioEnd = scenarioTracker.scenarioEnd(); if (scenarioBegin != null) { rootFolderName.append(scenarioBegin.toString()); if (scenarioEnd != null) { rootFolderName.append(" - "); } } if (scenarioEnd != null) { rootFolderName.append(scenarioEnd.toString()); } rootFolder.withDescription(rootFolderName.toString()); // Generate bounding box createKmlBoundingBox(rootFolder); // Generate situation folder if (createSituationFolder && snapshotTimes.size() >= 1) { createKmlSituationFolder(rootFolder, snapshotTimes.iterator().next()); if (snapshotTimes.size() > 1) { System.err.println("Only generates KML snapshot folder for first timestamp marked."); } } // Generate tracks folder if (createTracksFolder) { createKmlTracksFolder(rootFolder, e -> true); } // Generate movements folder if (createMovementsFolder) { createKmlMovementsAndIconsFolders(rootFolder); } return kml; }
From source file:com.pindroid.fragment.ViewBookmarkFragment.java
private void loadBookmark() { if (bookmark != null) { if (viewType == BookmarkViewType.VIEW) { Date d = new Date(bookmark.getTime()); if (bookmark.getDescription() != null && !bookmark.getDescription().equals("null")) mTitle.setText(bookmark.getDescription()); mUrl.setText(bookmark.getUrl()); if (bookmark.getNotes() != null && !bookmark.getNotes().equals("null") && !bookmark.getNotes().equals("")) { mNotes.setText(bookmark.getNotes()); notesSection.setVisibility(View.VISIBLE); } else { notesSection.setVisibility(View.GONE); }/*from ww w . j a v a 2s .co m*/ mTime.setText(d.toString()); mTags.setMovementMethod(LinkMovementMethod.getInstance()); SpannableStringBuilder tagBuilder = new SpannableStringBuilder(); if (bookmark.getTags().size() > 0) { for (Tag t : bookmark.getTags()) { addTag(tagBuilder, t, tagOnClickListener); } mTags.setText(tagBuilder); tagsSection.setVisibility(View.VISIBLE); } else { tagsSection.setVisibility(View.GONE); } if (isMyself()) { Uri.Builder ub = new Uri.Builder(); ub.scheme("content"); ub.authority(BookmarkContentProvider.AUTHORITY); ub.appendPath("bookmark"); ub.appendPath(Integer.toString(bookmark.getId())); getActivity().getContentResolver().unregisterContentObserver(observer); getActivity().getContentResolver().registerContentObserver(ub.build(), true, observer); mUsername.setText(bookmark.getAccount()); if (bookmark.getToRead() && bookmark.getShared()) { bookmarkIcon.setImageResource(R.drawable.ic_unread); } else if (!bookmark.getToRead() && bookmark.getShared()) { bookmarkIcon.setImageResource(R.drawable.ic_bookmark); } else if (bookmark.getToRead() && !bookmark.getShared()) { bookmarkIcon.setImageResource(R.drawable.ic_unread_private); } else if (!bookmark.getToRead() && !bookmark.getShared()) { bookmarkIcon.setImageResource(R.drawable.ic_bookmark_private); } } else { if (bookmark.getAccount() != null) { SpannableStringBuilder builder = new SpannableStringBuilder(); int start = builder.length(); builder.append(bookmark.getAccount()); int end = builder.length(); AccountSpan span = new AccountSpan(bookmark.getAccount()); span.setOnAccountClickListener(accountOnClickListener); builder.setSpan(span, start, end, 0); mUsername.setText(builder); } mUsername.setMovementMethod(LinkMovementMethod.getInstance()); } } else if (viewType == BookmarkViewType.READ) { showInWebView(Constants.INSTAPAPER_URL + bookmark.getUrl()); if (isMyself() && bookmark.getToRead() && SettingsHelper.getMarkAsRead(getActivity())) bookmarkSelectedListener.onBookmarkMark(bookmark); } else if (viewType == BookmarkViewType.WEB) { showInWebView(bookmark.getUrl()); } } else { clearView(); } }
From source file:com.clustercontrol.performance.monitor.factory.RunMonitorPerformance.java
/** * *//*from w w w . j a v a 2 s. c o m*/ @Override protected void notify(boolean isNode, String facilityId, int result, Date generationDate, MonitorRunResultInfo resultInfo) throws HinemosUnknown { // for debug if (m_log.isDebugEnabled()) { m_log.debug("notify() isNode = " + isNode + ", facilityId = " + facilityId + ", result = " + result + ", generationDate = " + generationDate.toString() + ", resultInfo = " + resultInfo.getMessage()); } // ?????? if (!m_monitor.getMonitorFlg()) { m_log.debug("notify() isNode = " + isNode + ", facilityId = " + facilityId + ", result = " + result + ", generationDate = " + generationDate.toString() + ", resultInfo = " + resultInfo.getMessage() + ", monitorFlg is false"); return; } // ID??????????? String notifyGroupId = resultInfo.getNotifyGroupId(); if (notifyGroupId == null || "".equals(notifyGroupId)) { return; } // OutputBasicInfo notifyInfo = new OutputBasicInfo(); notifyInfo.setPluginId(m_monitorTypeId); notifyInfo.setMonitorId(m_monitorId); notifyInfo.setApplication(m_monitor.getApplication()); // ? if (resultInfo.getDisplayName() != null && !"".equals(resultInfo.getDisplayName())) { // ??????????????? notifyInfo.setSubKey(resultInfo.getDisplayName()); } String facilityPath = new RepositoryControllerBean().getFacilityPath(facilityId, null); notifyInfo.setFacilityId(facilityId); notifyInfo.setScopeText(facilityPath); int priority = resultInfo.getPriority(); String message = resultInfo.getMessage(); String messageOrg = resultInfo.getMessageOrg(); notifyInfo.setPriority(priority); notifyInfo.setMessage(message); notifyInfo.setMessageOrg(messageOrg); if (generationDate == null) { notifyInfo.setGenerationDate(null); } else { notifyInfo.setGenerationDate(generationDate.getTime()); } // for debug if (m_log.isDebugEnabled()) { m_log.debug("notify() priority = " + priority + " , message = " + message + " , messageOrg = " + messageOrg + ", generationDate = " + generationDate); } // ? if (m_log.isDebugEnabled()) { m_log.debug("sending message" + " : priority=" + notifyInfo.getPriority() + " generationDate=" + notifyInfo.getGenerationDate() + " pluginId=" + notifyInfo.getPluginId() + " monitorId=" + notifyInfo.getMonitorId() + " facilityId=" + notifyInfo.getFacilityId() + " subKey=" + notifyInfo.getSubKey() + ")"); } new NotifyControllerBean().notify(notifyInfo, notifyGroupId); }
From source file:it.geosolutions.opensdi2.userexpiring.ExpiringTask.java
/** * This method check user expiring and notify the administrator *///from w w w. jav a2 s. c o m public void runExpiringUsers() { Date executionStart = new Date(); // check executing synchronized (userExpiringTaskStatus) { if (userExpiringTaskStatus.getStatus() == TaskState.Running) { userExpiringTaskStatus.setMessage( "task was running at " + new Date() + " while trying to execute the process again"); return; } // TODO syncronize on the status object // Log Start userExpiringTaskStatus.setStatus(TaskState.Running); userExpiringTaskStatus.setLastRun(executionStart.toString()); } // check connection to geostore if (!pingGeoStore()) { synchronized (userExpiringTaskStatus) { userExpiringTaskStatus.setStatus(TaskState.Stopped); userExpiringTaskStatus.setLastExecutionOutCome((ExecutionState.Error)); userExpiringTaskStatus.setMessage( "GeoStore is unreachable at:" + administratorGeoStoreClient.getGeostoreRestUrl()); } return; } else if (userExpiringTaskStatus.getMessage() != null) { // Remove the message if GeoStore is reachable again // TODO improve this check if (userExpiringTaskStatus.getMessage().contains("GeoStore is unreachable")) { userExpiringTaskStatus.setMessage(null); } } // Setup ExpiringUpdater updater = new ExpiringUpdater(); updater.setClient(administratorGeoStoreClient); updater.setDateFormat(dateFormat); updater.setAttributeName(expiringDateAttribute); // instantiate log element ExpireLogElement e = null; List<User> expired = null; // run try { // Check users and expire accounts expired = updater.checkUserList(); // add log entry to the execution log // only if some account expired boolean mailSuccess = true; if (expired != null && expired.size() > 0) { e = new ExpireLogElement(); // set users in log e.setExpiredUsers(getRestUsers(expired)); e.setDate(executionStart.toString()); // send checksum if (notifyTo != null) { mailSuccess = notifyAdminUserExpiring(expired, e); } if (notifyUsers && emailAttribute != null) { if (notifyUsersAccountExpiring(expired, e) && mailSuccess) { e.setEmailNotificationStatusSummary(ExecutionState.Success); } else { e.setEmailNotificationStatusSummary(ExecutionState.Error); mailSuccess = false; } } } synchronized (userExpiringTaskStatus) { userExpiringTaskStatus.setLastExecutionOutCome((ExecutionState.Success)); if (e != null) { e.setStatus(userExpiringTaskStatus.getLastExecutionOutCome()); } userExpiringTaskStatus.setStatus(TaskState.Stopped); } } catch (Exception ee) { synchronized (userExpiringTaskStatus) { userExpiringTaskStatus.setStatus(TaskState.Stopped); userExpiringTaskStatus.setLastExecutionOutCome((ExecutionState.Error)); userExpiringTaskStatus.setMessage(ee.getMessage()); if (e != null) { e.setStatus(userExpiringTaskStatus.getLastExecutionOutCome()); } } LOGGER.error("error during user expiring task execution", ee); } finally { // if the log element is initialized // an expiration occurred. userExpiringTaskStatus.setStatus(TaskState.Stopped); if (e != null) { userExpiringTaskStatus.addLog(e); } } }
From source file:gov.nih.nci.ncicb.tcga.dcc.dam.service.FilePackagerEnqueuer.java
/** * Schedule a job to delete the given <code>QuartzJobHistory</code>. * It should be scheduled at the same time the <code>FilePackagerBean</code> archive is scheduled for deletion. * * @param quartzJobHistory the <code>QuartzJobHistory</code> to delete * @param dateOfTrigger the Date at which the trigger should fire * @throws SchedulerException/* w w w. j a v a 2 s .co m*/ */ @Override public void queueQuartzJobHistoryDeletionJob(final QuartzJobHistory quartzJobHistory, final Date dateOfTrigger) throws SchedulerException { final String jobName = UUID.randomUUID().toString(); final JobDetail jobDetail = getJobDetail(); jobDetail.setName(jobName); jobDetail.setGroup(JOB_GROUP_QUARTZ_JOB_HISTORY_DELETION); jobDetail.getJobDataMap().put(JobDelegate.DATA_BEAN, quartzJobHistory); jobDetail.getJobDataMap().put(JobDelegate.JOB_BEAN_NAME, SPRING_BEAN_NAME_FOR_QUARTZ_JOB_HISTORY_DELETION_JOB); final Trigger trigger = getTrigger(jobDetail, dateOfTrigger); trigger.setPriority(PRIORITY_DELETION); log.info(new StringBuilder("Scheduling deletion of quartzJobHistory ").append(quartzJobHistory.getJobName()) .append(".").append(quartzJobHistory.getJobGroup()).append(" ") .append(getJobDetailString(jobDetail, trigger)).append(" at ").append(dateOfTrigger.toString())); scheduleSmallJobs(jobDetail, trigger); }
From source file:com.haulmont.cuba.gui.components.formatters.DateFormatter.java
@Override public String format(Date value) { if (value == null) { return null; }//www. ja v a 2 s .c o m String format = element.attributeValue("format"); if (StringUtils.isBlank(format)) { String type = element.attributeValue("type"); if (type != null) { FormatStrings formatStrings = Datatypes.getFormatStrings(userSessionSource.getLocale()); if (formatStrings == null) throw new IllegalStateException( "FormatStrings are not defined for " + userSessionSource.getLocale()); switch (type) { case "DATE": format = formatStrings.getDateFormat(); break; case "DATETIME": format = formatStrings.getDateTimeFormat(); break; default: throw new RuntimeException("Illegal formatter type value"); } } } if (StringUtils.isBlank(format)) { return value.toString(); } else { if (format.startsWith("msg://")) { format = messages.getMainMessage(format.substring(6, format.length())); } DateFormat df = new SimpleDateFormat(format); return df.format(value); } }
From source file:com.housekeeper.ar.healthhousekeeper.personalinfo.ModifyInfoActivity.java
public void modify() { try {//from w w w. jav a2s. co m if (usernameET.getText().toString().equals("")) { // Toast.makeText(RegisterActivity.this, "??", // Toast.LENGTH_LONG).show(); toastCommom.ToastShow(ModifyInfoActivity.this, (ViewGroup) findViewById(R.id.toast_layout_root), "??"); return; } if (nameET.getText().toString().equals("")) { // Toast.makeText(RegisterActivity.this, "??", // Toast.LENGTH_LONG).show(); toastCommom.ToastShow(ModifyInfoActivity.this, (ViewGroup) findViewById(R.id.toast_layout_root), "??"); return; } if (idET.getText().toString().equals("")) { Toast.makeText(ModifyInfoActivity.this, "??", Toast.LENGTH_LONG).show(); return; } SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Log.i(TAG, "birthdayStr " + birthdayStr); try { // birthdayStr= "1983-07-02 00:00:00"; String time = birthdayStr + " 00:00:00"; Log.i(TAG, "time " + time); Date date = format.parse(time); Log.i(TAG, "? " + date.toString()); } catch (ParseException e) { Toast.makeText(ModifyInfoActivity.this, "??", Toast.LENGTH_LONG).show(); e.printStackTrace(); Log.i(TAG, "??"); return; } params.put("userId", usernameET.getText().toString());//str params.put("name", nameET.getText().toString());//str params.put("sex", sexStr);//str params.put("workId", workIdEditText.getText().toString()); birthdayStr = yearStr + "-" + monthStr + "-" + dayStr; params.put("birthday", birthdayStr.contains("null") ? joDoc.getString("birthday") : birthdayStr);//str params.put("identity", idET.getText().toString());//str // params.put("jobTitleId", idJobTitlesInt);//int // params.put("licenseNO", yszET.getText().toString());//str // params.put("licenseNOPic", zyysAddr==null?joDoc.getString("licenseNOPic"):zyysAddr);//str // params.put("certificateNo", zczET.getText().toString());//str // params.put("certificateNoPic", yszcAddr==null?joDoc.getString("certificateNoPic"):yszcAddr);//str // params.put("jobTitleNoPic", zcpsAddr==null?joDoc.getString("jobTitleNoPic"):zcpsAddr);//str // params.put("jobTitleNo", zcpsET.getText().toString());//str params.put("province", shengStr); params.put("city", shiStr); params.put("hospital", yyStr); params.put("phone", telET.getText().toString());//str params.put("email", mailET.getText().toString());//str // params.put("departmentId", idDepartmentInt);//int //params.put("departmentType", ksflStr); // params.put("skill", skillET.getText().toString());//str // params.put("description", detailET.getText().toString());//str //params.put("titlePicture", "picture Url"); params.put("photoPic", photoAddr == null ? joDoc.getString("photoPic") : photoAddr);//str // params.put("meetPlace", addressEdit.getText().toString()); Log.i(TAG, "params:" + params.toString()); httpUrl = http + regUrl; Log.i(TAG, "httpUrl:" + httpUrl);//str HttpPut put = HttpUtil.getPut(httpUrl, params); JSONObject joRev = HttpUtil.getString(put); //HttpPost post = HttpUtil.getPost(httpUrl, params); // JSONObject joRev = HttpUtil.getString(post, 3); showStr = joRev.getString("result"); resultStr = joRev.getString("resultMessage"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { } //handler.sendMessage(msg); if (showStr.equals("200")) { Log.d(TAG, "resultStr:" + resultStr); // Toast.makeText(RegisterActivity.this, "??", // Toast.LENGTH_LONG).show(); toastCommom.ToastShow(ModifyInfoActivity.this, (ViewGroup) findViewById(R.id.toast_layout_root), "??"); Intent intent = new Intent(ModifyInfoActivity.this, GuidanceBottomTabActivity.class); startActivity(intent); //pDialog.dismiss(); ModifyInfoActivity.this.finish(); } else { // Toast.makeText(RegisterActivity.this, resultStr, // Toast.LENGTH_LONG).show(); toastCommom.ToastShow(ModifyInfoActivity.this, (ViewGroup) findViewById(R.id.toast_layout_root), resultStr + " "); } }