List of usage examples for org.joda.time LocalDateTime toDateTime
public DateTime toDateTime()
From source file:com.heisenberg.impl.instance.ActivityInstanceImpl.java
License:Apache License
public void setEnd(LocalDateTime end) { this.end = end; if (start != null && end != null) { this.duration = new Duration(start.toDateTime(), end.toDateTime()).getMillis(); }/*from www . j ava2 s . c o m*/ if (updates != null) { updates.isEndChanged = true; propagateActivityInstanceChange(parent); } }
From source file:com.heisenberg.impl.instance.WorkflowInstanceImpl.java
License:Apache License
public void setEnd(LocalDateTime end) { this.end = end; if (start != null && end != null) { this.duration = new Duration(start.toDateTime(), end.toDateTime()).getMillis(); }/*from w w w . j a v a2s . com*/ if (updates != null) { getUpdates().isEndChanged = true; } }
From source file:com.helger.poi.excel.WorkbookCreationHelper.java
License:Apache License
/** * @param aValue// w ww. j a v a 2 s .c o m * The value to be set. * @return A new cell in the current row of the current sheet with the passed * value */ @Nonnull public Cell addCell(@Nonnull final LocalDateTime aValue) { return addCell(aValue.toDateTime()); }
From source file:com.mysema.query.sql.types.LocalDateTimeType.java
License:Apache License
@Override public void setValue(PreparedStatement st, int startIndex, LocalDateTime value) throws SQLException { st.setTimestamp(startIndex, new Timestamp(value.toDateTime().getMillis())); }
From source file:com.sam.moca.server.expression.operators.arith.MinusExpression.java
License:Open Source License
protected MocaValue doOper(MocaValue left, MocaValue right) { if (left.getType() == MocaType.DATETIME) { if (right.getType() == MocaType.DOUBLE || right.getType() == MocaType.INTEGER) { Date d = left.asDate(); // If the left side is null, return a null result. if (d == null) { return new MocaValue(MocaType.DATETIME, null); }/* w w w .ja v a 2 s . c o m*/ LocalDateTime dt = new LocalDateTime(d); int wholeDays = right.asInt(); double dayPart = right.asDouble() - wholeDays; int msDiff = (int) (dayPart * 1000.0 * 3600.0 * 24.0); dt = dt.minusDays(wholeDays).minusMillis(msDiff); return new MocaValue(MocaType.DATETIME, dt.toDateTime().toDate()); } else if (right.getType() == MocaType.DATETIME) { Date leftDate = left.asDate(); Date rightDate = right.asDate(); // If either the left side or the right side is null, return null if (leftDate == null || rightDate == null) { return new MocaValue(MocaType.DOUBLE, null); } DateTime leftDt = new DateTime(leftDate); DateTime rightDt = new DateTime(rightDate); int fullDays = Days.daysBetween(rightDt, leftDt).getDays(); LocalTime leftTime = new LocalTime(leftDt); LocalTime rightTime = new LocalTime(rightDt); int ms = leftTime.getMillisOfDay() - rightTime.getMillisOfDay(); double partial = ((double) ms / (1000.0 * 3600.0 * 24.0)); if (partial < 0.0 && leftDate.after(rightDate)) { partial += 1.0; } else if (partial > 0.0 && rightDate.after(leftDate)) { partial -= 1.0; } double daysDiff = (double) fullDays + partial; return new MocaValue(MocaType.DOUBLE, daysDiff); } } else { if (left.getType() == MocaType.DOUBLE || right.getType() == MocaType.DOUBLE) { return new MocaValue(MocaType.DOUBLE, Double.valueOf(left.asDouble() - right.asDouble())); } else { return new MocaValue(MocaType.INTEGER, Integer.valueOf(left.asInt() - right.asInt())); } } return null; }
From source file:com.sam.moca.server.expression.operators.arith.PlusExpression.java
License:Open Source License
private MocaValue addToDate(MocaValue date, MocaValue days) { Date d = date.asDate();// w w w . jav a2 s . c o m // If the left side is null, return a null result. if (d == null) { return new MocaValue(MocaType.DATETIME, null); } MocaType daysType = days.getType(); if (daysType == MocaType.INTEGER || daysType == MocaType.DOUBLE) { LocalDateTime dt = new LocalDateTime(d); int wholeDays = days.asInt(); double dayPart = days.asDouble() - wholeDays; int msDiff = (int) (dayPart * 1000.0 * 3600.0 * 24.0); dt = dt.plusDays(wholeDays).plusMillis(msDiff); return new MocaValue(MocaType.DATETIME, dt.toDateTime().toDate()); } else { return date; } }
From source file:com.temenos.interaction.jdbc.producer.sql.SQLExpressionVisitor.java
License:Open Source License
@Override public void visit(DateTimeLiteral expr) { // Get the joda representation LocalDateTime jodaTime = expr.getValue(); // Convert it to SQL representation Timestamp timeStamp = new Timestamp(jodaTime.toDateTime().getMillis()); // Print it out. String timeStampStr = timeStamp.toString(); appendFormatted("'%s'", timeStampStr); }
From source file:com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.java
License:Open Source License
private Long getMillisForHour(LocalDateTime usageStartTime) { return usageStartTime.toDateTime().getMillis(); }
From source file:com.wealdtech.jackson.modules.LocalDateTimeSerializer.java
License:Open Source License
@Override public void serialize(final LocalDateTime value, final JsonGenerator gen, final SerializerProvider provider) throws IOException { gen.writeString(formatter.print(value.toDateTime().withZone(DateTimeZone.UTC))); }
From source file:controllers.PrettyTimeController.java
License:Apache License
public Result index(Context context) { // Only render the page. It contains some language specific strings. // It will use the requested language (or a fallback language) // from Accept-Language header Result result = Results.html(); // just in case we set the language => we remove it... lang.clearLanguage(result);//from w w w . j a v a2 s .c o m // 25 works for summertime, too. LocalDateTime localDateTime = LocalDateTime.now().minusHours(25); result.render("date", new Date(localDateTime.toDateTime().getMillis())); return result; }