@Override public org.joda.time.DateMidnight convert(DateTime source) { return source.toDateMidnight(); } }
@Override public org.joda.time.DateMidnight convert(DateTime source) { return source.toDateMidnight(); } }
/** * Parses a {@code DateMidnight} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */ public static DateMidnight parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toDateMidnight(); }
/** * Parses a {@code DateMidnight} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */ public static DateMidnight parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toDateMidnight(); }
/** * Parses a {@code DateMidnight} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */ public static DateMidnight parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toDateMidnight(); }
@Override public DateMidnight deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // We'll accept either long (timestamp) or array: if (jp.isExpectedStartArrayToken()) { jp.nextToken(); // VALUE_NUMBER_INT int year = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int month = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int day = jp.getIntValue(); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "after DateMidnight ints"); } return new DateMidnight(year, month, day); } switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: return new DateMidnight(jp.getLongValue()); case VALUE_STRING: DateTime local = parseLocal(jp); if (local == null) { return null; } return local.toDateMidnight(); } throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "expected JSON Array, Number or String"); } }
void removeDays(int i) { DateTime first = beginningOfSeries(); DateTime midnight = first.toDateMidnight().toDateTime(); DateTime cutoff = midnight.plusDays(i); prices = new TreeMap<DateTime, BigDecimal>(prices.tailMap(cutoff)); } }
public DateTime closeOnDay(DateTime date) { DateTime midnight = date.toDateMidnight().toDateTime(); DateTime nextDay = midnight.plusDays(1); return prices.floorEntry(nextDay).getKey(); }
public BigDecimal openOnDay(DateTime date) { DateTime midnight = date.toDateMidnight().toDateTime(); NavigableMap<DateTime, BigDecimal> previousPrices = prices.subMap(midnight, true, date, true); return previousPrices.firstEntry().getValue(); }
@Override public boolean buy(DateTime time, Session session) { if (session.inMarket(time)) { return false; } BigDecimal open = asset.getTimeSeries().openOnDay(time); BigDecimal current = asset.priceAt(time); BigDecimal increase = current.subtract(open); final DateTime midnight = time.toDateMidnight().toDateTime(); final DateTime nextDay = midnight.plusDays(1); boolean tradedToday = (Collections2.filter(session.getTrades(), new Predicate<Trade>() { @Override public boolean apply(Trade trade) { return trade.getOpen().compareTo(midnight) > 0 && trade.getClose().compareTo(nextDay) < 0; } })).size() > 0; return !tradedToday && increase.compareTo(buyTrigger) >= 0; }
/** * Parses a {@code DateMidnight} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */ public static DateMidnight parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toDateMidnight(); }
/** * Parses a {@code DateMidnight} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */ public static DateMidnight parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toDateMidnight(); }
public DateMidnight getAubEndDate() { if (this.aubEndDate == null) { return null; } return new DateTime(this.aubEndDate).toDateMidnight(); }
/** * Parses a {@code DateMidnight} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */ public static DateMidnight parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toDateMidnight(); }
@Override public DateMidnight deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // We'll accept either long (timestamp) or array: if (jp.isExpectedStartArrayToken()) { jp.nextToken(); // VALUE_NUMBER_INT int year = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int month = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int day = jp.getIntValue(); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "after DateMidnight ints"); } return new DateMidnight(year, month, day); } switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: return new DateMidnight(jp.getLongValue()); case VALUE_STRING: DateTime local = parseLocal(jp); if (local == null) { return null; } return local.toDateMidnight(); } throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "expected JSON Array, Number or String"); } }
@PostLoad @PostUpdate @PostPersist void init() { this.startDateMidnight = this.start.toDateMidnight(); this.endDateMidnight = this.end.toDateMidnight(); }
public DateMidnight convert(String value, Class<? extends DateMidnight> type, ResourceBundle bundle) { try { DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDate()); if (out == null) { return null; } return out.toDateMidnight(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } } }
@Override protected Money calculatePenaltyAmount(Event event, DateTime when, BigDecimal discountPercentage) { if (when.toDateMidnight().compareTo(getWhenStartToApplyPenalty().toDateMidnight()) >= 0) { return new Money(calculateMonthPenalty(event, discountPercentage).multiply( new BigDecimal(getNumberOfMonthsToChargePenalty(when)))); } else { return Money.ZERO; } }
public void setEndTime(DateTime endTime) { endDate = endTime.toDateMidnight(); endHour = endTime.getHourOfDay(); endMinute = endTime.getMinuteOfHour(); endHourMinute = new LocalTime(endTime); }
@KeyWeight(10) @SupplierKey("at midnight") @API("1.0.0") public ReadableDateTime toDateMidnight( @KeyValue ReadableDateTime dateTime ) { return dateTime.toDateTime().toDateMidnight(); }