List of usage examples for org.joda.time LocalDateTime toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:org.directwebremoting.convert.LocalDateTimeConverter.java
License:Apache License
public OutboundVariable convertOutbound(Object data, OutboundContext outboundContext) throws ConversionException { long milliSeconds; if (data instanceof DateTime) { DateTime dateTime = (DateTime) data; milliSeconds = dateTime.getMillis(); } else if (data instanceof LocalDateTime) { LocalDateTime date = (LocalDateTime) data; milliSeconds = date.toDateTime().toDate().getTime(); } else {/* w w w . jav a 2 s.c o m*/ throw new ConversionException(data.getClass()); } return new NonNestedOutboundVariable("new Date(" + milliSeconds + ")"); }
From source file:org.fixb.quickfix.QuickFixFieldMapBuilder.java
License:Apache License
protected FixMessageBuilder<M> setField(FieldMap message, int tag, LocalDateTime value) { message.setUtcTimeStamp(tag, value.toDateTime(DateTimeZone.UTC).toDate()); return this; }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
/** * Returns the timestamp of the start of current period of the budget * @return Start timestamp in milliseconds */// ww w .j a v a 2 s . c om public long getStartofCurrentPeriod() { LocalDateTime localDate = new LocalDateTime(); int interval = mRecurrence.getPeriodType().getMultiplier(); switch (mRecurrence.getPeriodType()) { case DAY: localDate = localDate.millisOfDay().withMinimumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMinimumValue().minusDays(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMinimumValue().minusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMinimumValue().minusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
/** * Returns the end timestamp of the current period * @return End timestamp in milliseconds *//*from ww w. j av a2 s . c om*/ public long getEndOfCurrentPeriod() { LocalDateTime localDate = new LocalDateTime(); int interval = mRecurrence.getPeriodType().getMultiplier(); switch (mRecurrence.getPeriodType()) { case DAY: localDate = localDate.millisOfDay().withMaximumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMaximumValue().plusWeeks(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMaximumValue().plusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMaximumValue().plusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
public long getStartOfPeriod(int periodNum) { LocalDateTime localDate = new LocalDateTime(mRecurrence.getPeriodStart().getTime()); int interval = mRecurrence.getPeriodType().getMultiplier() * periodNum; switch (mRecurrence.getPeriodType()) { case DAY://www . j ava 2 s .c o m localDate = localDate.millisOfDay().withMinimumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMinimumValue().minusDays(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMinimumValue().minusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMinimumValue().minusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
/** * Returns the end timestamp of the period * @param periodNum Number of the period * @return End timestamp in milliseconds of the period *///from w w w . j av a 2 s . c o m public long getEndOfPeriod(int periodNum) { LocalDateTime localDate = new LocalDateTime(); int interval = mRecurrence.getPeriodType().getMultiplier() * periodNum; switch (mRecurrence.getPeriodType()) { case DAY: localDate = localDate.millisOfDay().withMaximumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMaximumValue().plusWeeks(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMaximumValue().plusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMaximumValue().plusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.informea.odata.data.db.DatabaseDataProvider.java
License:Open Source License
/** * Transform query from OData query into SQL Hibernate query * @param updatedColumn Column to filter by * @param q OData query/* ww w. jav a 2 s . c o m*/ * @return Hibernate Criteria object, null if no filter have to be set */ protected Criterion filterLatest(String updatedColumn, QueryInfo q) { if (q != null && q.filter instanceof GtExpression) { GtExpression filter = (GtExpression) q.filter; log.info(filter.toString()); if (filter.getLHS() instanceof EntitySimpleProperty) { EntitySimpleProperty l = (EntitySimpleProperty) filter.getLHS(); if ("published".equals(l.getPropertyName())) { if (filter.getRHS() instanceof DateTimeLiteral) { LocalDateTime dt = ((DateTimeLiteral) filter.getRHS()).getValue(); Date latest = dt.toDateTime().toDate(); log.info(String.format("Retrieving latest decisions after %s", latest.toString())); return Restrictions.ge("updated", latest); } } } } return null; }
From source file:org.javarosa.core.model.utils.DateUtils.java
License:Apache License
public static Date getDate(DateFields f, String timezone) { LocalDateTime ldt = getLocalDateTime(f); return timezone == null ? ldt.toDate() : ldt.toDate(TimeZone.getTimeZone(timezone)); }
From source file:org.jtwig.functions.builtin.DateFunctions.java
License:Apache License
private Date modify(String modifyString, LocalDateTime localDateTime) throws FunctionException { LocalDateTime result; Matcher matcher = compile(MODIFY_PATTERN).matcher(modifyString); matcher.find();//from w w w .ja va 2 s. c om int signal = 1; if (matcher.group(1).equals("-")) signal = -1; int val = Integer.valueOf(matcher.group(2)) * signal; String type = matcher.group(3).toLowerCase(); if (type.startsWith("day")) result = localDateTime.plusDays(val); else if (type.startsWith("month")) result = localDateTime.plusMonths(val); else if (type.startsWith("year")) result = localDateTime.plusYears(val); else if (type.startsWith("second")) result = localDateTime.plusSeconds(val); else if (type.startsWith("hour")) result = localDateTime.plusHours(val); else if (type.startsWith("minute")) result = localDateTime.plusMinutes(val); else throw new FunctionException("Unknown type " + matcher.group(3)); return result.toDate(); }
From source file:org.kitodo.production.services.data.UserService.java
License:Open Source License
/** * Add filter to user./* ww w .ja va 2 s. co m*/ * * @param user * object * @param userFilter * String */ private void addFilterToUser(User user, String userFilter) throws DataException { LocalDateTime localDateTime = new LocalDateTime(); Filter filter = new Filter(); filter.setValue(userFilter); filter.setCreationDate(localDateTime.toDate()); filter.setUser(user); ServiceManager.getFilterService().save(filter); refresh(user); }