List of usage examples for org.joda.time LocalDateTime LocalDateTime
public LocalDateTime(Object instant)
From source file:me.vertretungsplan.parser.IphisParser.java
License:Mozilla Public License
private Boolean login() throws CredentialInvalidException, IOException { final UserPasswordCredential userPasswordCredential = (UserPasswordCredential) credential; final String username = userPasswordCredential.getUsername(); final String password = userPasswordCredential.getPassword(); JSONObject payload = new JSONObject(); try {// w w w . jav a 2s. com payload.put("school", kuerzel); payload.put("user", username); payload.put("type", scheduleData.getType()); payload.put("password", password); } catch (JSONException e) { e.printStackTrace(); } httpPost(api + "/login", "UTF-8", payload.toString(), ContentType.APPLICATION_JSON); final String httpResponse = httpPost(api + "/login", "UTF-8", payload.toString(), ContentType.APPLICATION_JSON); final JSONObject token; try { token = new JSONObject(httpResponse); final String key = Base64.encodeBase64String(jwt_key.getBytes()); final Claims jwtToken = Jwts.parser().setSigningKey(key).parseClaimsJws(token.getString("token")) .getBody(); assert jwtToken.getSubject().equals("vertretungsplan.me"); authToken = token.getString("token"); website = jwtToken.getIssuer(); lastUpdate = new LocalDateTime(token.getLong("stand") * 1000); } catch (SignatureException | JSONException e) { throw new CredentialInvalidException(); } return true; }
From source file:me.vertretungsplan.parser.WebUntisParser.java
License:Mozilla Public License
private LocalDateTime getLastImport() throws JSONException, CredentialInvalidException, IOException, UnauthorizedException { return new LocalDateTime(request("getLatestImportTime")); }
From source file:mekhq.Utilities.java
License:Open Source License
/** @return the current date as a DateTime time stamp for midnight in UTC time zone */ public static DateTime getDateTimeDay(Calendar cal) { return new LocalDateTime(cal).toDateTime(DateTimeZone.UTC); }
From source file:mekhq.Utilities.java
License:Open Source License
/** @return the current date as a DateTime time stamp for midnight in UTC time zone */ public static DateTime getDateTimeDay(Date date) { return new LocalDateTime(date).toDateTime(DateTimeZone.UTC); }
From source file:net.opentsdb.odata.OpenTSDBProducer.java
License:Open Source License
private OEntity DataPointToOEntity(DataPoint dp, EdmEntitySet entitySet, OEntityKey entityKey, String metric, Map<String, String> tags) { List<OProperty<?>> properties = new ArrayList<OProperty<?>>(); List<OLink> links = new ArrayList<OLink>(); properties.add(OProperties.string("Name", metric)); LocalDateTime ldt = new LocalDateTime(dp.timestamp() * 1000); properties.add(OProperties.datetime("Timestamp", ldt)); if (dp.isInteger()) { Long value = dp.longValue(); properties.add(OProperties.double_("Value", value.doubleValue())); } else {//w ww . j a v a 2 s .c o m properties.add(OProperties.double_("Value", dp.doubleValue())); } for (String tag : tags.keySet()) { properties.add(OProperties.string(tag, tags.containsKey(tag) ? tags.get(tag) : null)); } return OEntities.create(entitySet, entityKey, properties, links); }
From source file:net.rrm.ehour.report.reports.element.AssignmentAggregateReportElement.java
License:Open Source License
/** * Get the progress (booked hours) in percentage of the allotted hours, leaving out the overrun * or for date ranges use the current date vs start & end date (if they're both null) *//*from w w w. j ava2 s . c o m*/ public Optional<Float> getProgressPercentage() { Optional<Float> percentage = Optional.absent(); if (projectAssignment == null) { return Optional.absent(); } if (projectAssignment.getAssignmentType().isAllottedType()) { if (hours != null && projectAssignment.getAllottedHours() != null && hours.floatValue() > 0 && projectAssignment.getAllottedHours() > 0) { percentage = Optional.of((hours.floatValue() / projectAssignment.getAllottedHours()) * 100); } } else if (projectAssignment.getAssignmentType().isDateType() && projectAssignment.getDateStart() != null && projectAssignment.getDateEnd() != null) { LocalDateTime now = LocalDateTime.now(); LocalDateTime start = new LocalDateTime(projectAssignment.getDateStart()); LocalDateTime end = new LocalDateTime(projectAssignment.getDateEnd()); if (now.isBefore(start)) { percentage = Optional.of(0f); } else if (now.isAfter(end)) { percentage = Optional.of(100f); } else { float totalRange = Days.daysBetween(start, end).getDays(); float daysConsumed = Days.daysBetween(start, now).getDays(); percentage = Optional.of((daysConsumed / totalRange) * 100); } // if percentage is above 100 for daterange the user can't book anymore hours // so don't display more than 100% if (percentage.get() > 100) { percentage = Optional.of(100f); } } return percentage; }
From source file:nl.gmt.data.contrib.joda.PersistentLocalDateTime.java
License:Apache License
public Object nullSafeGet(ResultSet resultSet, String string, SessionImplementor session, Object owner) throws SQLException { Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string, session, owner); if (timestamp == null) { return null; }// ww w .ja v a2s . co m return new LocalDateTime(timestamp); }
From source file:nl.gmt.data.contrib.joda.PersistentLocalDateTime.java
License:Apache License
@Override @Deprecated public Object fromXMLString(String string) { return new LocalDateTime(string); }
From source file:org.apache.cayenne.joda.access.types.LocalDateTimeType.java
License:Apache License
@Override public LocalDateTime materializeObject(ResultSet rs, int index, int type) throws Exception { if (rs.getTimestamp(index) != null) { return new LocalDateTime(rs.getTimestamp(index).getTime()); } else {/*from w w w . j a v a 2 s . c o m*/ return null; } }
From source file:org.apache.cayenne.joda.access.types.LocalDateTimeType.java
License:Apache License
@Override public LocalDateTime materializeObject(CallableStatement rs, int index, int type) throws Exception { if (type == Types.TIMESTAMP && rs.getTimestamp(index) != null) { return new LocalDateTime(rs.getTimestamp(index).getTime()); } else {// www .j a va2 s .c o m return null; } }