List of usage examples for org.joda.time DateTime DateTime
public DateTime(Object instant)
From source file:br.edu.utfpr.cm.JGitMinerWeb.services.metric.social.TempoDeResposta.java
@Override public void calculateMetric(AuxAllMetrics pair) { Comparator comparator = new Comparator() { @Override//from w w w. j a v a 2 s . c o m public int compare(Object obj1, Object obj2) { EntityComment to1 = (EntityComment) obj1; EntityComment to2 = (EntityComment) obj2; return to1.getCreatedAt().compareTo(to2.getCreatedAt()); } }; for (EntityPullRequest pullRequest : pair.getPullRequests()) { DateTime dataAnterior = null; Integer mean = 0; // System.out.println("comments size: " + pullRequest.getIssue().getComments().size()); try { List<EntityComment> comentarios = Lists.newArrayList(pullRequest.getIssue().getComments()); Collections.sort(comentarios, comparator); for (EntityComment comment : comentarios) { if (comentarios.indexOf(comment) != 0) { int anterior = comentarios.indexOf(comment) - 1; dataAnterior = new DateTime(comentarios.get(anterior).getCreatedAt()); mean += Hours.hoursBetween(dataAnterior, new DateTime(comment.getCreatedAt())).getHours(); } } if (comentarios.size() > 0) { mean = mean / comentarios.size(); } result.put(pair.getId(), mean); } catch (Exception e) { System.out.println("Erro"); System.out.println(e.toString()); } } }
From source file:c3.ops.priam.backup.AbstractBackupPath.java
License:Apache License
public static String formatDate(Date d) { return new DateTime(d).toString(FMT); }
From source file:c3.ops.priam.resources.BackupServlet.java
License:Apache License
private JSONObject constructJsonResponse(JSONObject object, Iterator<AbstractBackupPath> it, String filter) throws Exception { int fileCnt = 0; filter = filter.contains("?") ? filter.substring(0, filter.indexOf("?")) : filter; try {//from www .j a v a2 s . c o m JSONArray jArray = new JSONArray(); while (it.hasNext()) { AbstractBackupPath p = it.next(); if (!filter.isEmpty() && BackupFileType.valueOf(filter) != p.getType()) continue; JSONObject backupJSON = new JSONObject(); backupJSON.put("bucket", config.getBackupPrefix()); backupJSON.put("filename", p.getRemotePath()); backupJSON.put("app", p.getClusterName()); backupJSON.put("region", p.getRegion()); backupJSON.put("token", p.getToken()); backupJSON.put("ts", new DateTime(p.getTime()).toString(FMT)); backupJSON.put("instance_id", p.getInstanceIdentity().getInstance().getInstanceId()); backupJSON.put("uploaded_ts", new DateTime(p.getUploadedTs()).toString(FMT)); if ("meta".equalsIgnoreCase(filter)) { List<AbstractBackupPath> allFiles = metaData.get(p); long totalSize = 0; for (AbstractBackupPath abp : allFiles) totalSize = totalSize + abp.getSize(); backupJSON.put("num_files", Long.toString(allFiles.size())); // keyValues.put("TOTAL-SIZE", Long.toString(totalSize)); // // Add Later } fileCnt++; jArray.put(backupJSON); } object.put("files", jArray); object.put("num_files", fileCnt); } catch (JSONException jse) { logger.info("Caught JSON Exception --> " + jse.getMessage()); } return object; }
From source file:ca.farrelltonsolar.classic.LogEntry.java
License:Apache License
public DateTime getLogDate() { long dateMillis = logs.getLong("LogDate"); return new DateTime(dateMillis); }
From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java
License:Open Source License
public DatePicker createDateField() { final DatePicker retVal = new DatePicker(); final DateTime sessionDate = getEditor().getSession().getDate(); if (sessionDate != null) retVal.setDateTime(sessionDate); retVal.getTextField().getDocument().addDocumentListener(new DocumentListener() { void dateFieldUpdate() { final DateTime selectedDate = retVal.getDateTime(); final DateTime newDate = new DateTime(selectedDate); final SessionDateEdit edit = new SessionDateEdit(getEditor(), newDate, getEditor().getSession().getDate()); edit.setSource(dateField);/*from ww w. j av a 2s. c o m*/ getEditor().getUndoSupport().postEdit(edit); } @Override public void insertUpdate(DocumentEvent e) { if (!dateField.isValueAdjusing()) dateFieldUpdate(); } @Override public void removeUpdate(DocumentEvent e) { if (!dateField.isValueAdjusing()) dateFieldUpdate(); } @Override public void changedUpdate(DocumentEvent e) { } }); return retVal; }
From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java
License:Open Source License
private void updateSessionDate() { final SessionEditor editor = getEditor(); final Session session = editor.getDataModel().getSession(); final DateTime currentDate = session.getDate(); final DateTime newDate = new DateTime(dateField); if (!currentDate.isEqual(newDate)) { final SessionDateEdit edit = new SessionDateEdit(getEditor(), newDate, currentDate); edit.setSource(dateField);//from w w w . j a v a 2 s . c o m editor.getUndoSupport().postEdit(edit); } }
From source file:ca.phon.project.LocalProject.java
License:Open Source License
@Override public DateTime getSessionModificationTime(String corpus, String session) { final File sessionFile = getSessionFile(corpus, session); long modTime = 0L; if (sessionFile.exists()) { modTime = sessionFile.lastModified(); }// ww w.j a v a 2 s .co m return new DateTime(modTime); }
From source file:ca.phon.query.db.xml.XMLQuery.java
License:Open Source License
@Override public DateTime getDate() { final XMLGregorianCalendar xmlDate = query.getDate(); // ensure timezone neutral xmlDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED); return new DateTime(xmlDate.toGregorianCalendar()); }
From source file:ca.phon.ui.text.DatePicker.java
License:Open Source License
public void onShowMonthView() { final JXMonthView monthView = getMonthView(); monthView.setTraversable(true);//from w w w .j av a2 s .c o m monthView.setBorder(BorderFactory.createEtchedBorder()); if (textField.getValue() != null) { monthView.setFirstDisplayedDay(textField.getValue().toDate()); monthView.setSelectionDate(textField.getValue().toDate()); } monthView.getSelectionModel().addDateSelectionListener(new DateSelectionListener() { @Override public void valueChanged(DateSelectionEvent ev) { textField.setValue(new DateTime(monthView.getSelectionDate())); } }); final JPopupMenu popup = new JPopupMenu(); popup.add(monthView); popup.show(monthViewButton, 0, monthViewButton.getHeight()); }
From source file:ca.ualberta.physics.cssdp.dao.type.PersistentDateTime.java
License:Apache License
@Override public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { Timestamp timestamp = rs.getTimestamp(names[0]); if (timestamp != null) { DateTime dateTime = new DateTime(timestamp); return dateTime; } else {/*from www .ja v a2s . c o m*/ return null; } }