List of usage examples for org.joda.time DateMidnight DateMidnight
public DateMidnight()
ISOChronology
in the default time zone. From source file:org.projectforge.framework.xstream.converter.JodaDateTimeConverter.java
License:Open Source License
Object parse(final String data) { try {/* w w w .j av a2 s .co m*/ final DateTimeFormatter parseFormat = DateTimeFormat.forPattern(ISO_FORMAT); final DateTime date = parseFormat.withZone(DateTimeZone.UTC).parseDateTime(data); final DateTimeZone dateTimeZone = ThreadLocalUserContext.getDateTimeZone(); return new DateTime(date, dateTimeZone); } catch (final Exception ex) { log.error("Can't parse DateMidnight: " + data); return new DateMidnight(); } }
From source file:org.projectforge.xstream.JodaDateTimeConverter.java
License:Open Source License
Object parse(final String data) { try {// ww w .jav a 2 s .co m final DateTimeFormatter parseFormat = DateTimeFormat.forPattern(ISO_FORMAT); final DateTime date = parseFormat.withZone(DateTimeZone.UTC).parseDateTime(data); final DateTimeZone dateTimeZone = PFUserContext.getDateTimeZone(); return new DateTime(date, dateTimeZone); } catch (final Exception ex) { log.error("Can't parse DateMidnight: " + data); return new DateMidnight(); } }
From source file:org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo.java
License:Apache License
public RouteSpecification buildRouteSpecification(ValueBuilderFactory vbf, Location origin, Location destination, Date deadline) { if (origin == destination) { throw new RuntimeException("Origin location can't be same as destination location."); }/* w ww . j a v a 2 s .c om*/ if (deadline == null) { throw new RuntimeException("Arrival deadline cannot be null."); } Date endOfToday = new DateMidnight().plusDays(1).toDate(); if (deadline.before(endOfToday)) { throw new RuntimeException("Arrival deadline is in the past or Today." + "\nDeadline " + deadline + "\nToday (midnight) " + endOfToday); } ValueBuilder<RouteSpecification> routeSpec = vbf.newValueBuilder(RouteSpecification.class); routeSpec.prototype().origin().set(origin); routeSpec.prototype().destination().set(destination); routeSpec.prototype().arrivalDeadline().set(deadline); return routeSpec.newInstance(); }
From source file:org.specrunner.converters.core.ConverterDateMidnightCurrentTemplate.java
License:Open Source License
@Override protected DateMidnight instance() { return new DateMidnight(); }
From source file:org.wicketstuff.ddcalendar.CalendarWeek.java
License:Apache License
public CalendarWeek() { DateMidnight now = new DateMidnight(); this.year = now.getYear(); this.week = now.getWeekOfWeekyear(); }
From source file:ru.org.linux.tag.TagPageController.java
License:Apache License
private static ImmutableListMultimap<String, Topic> datePartition(Iterable<Topic> topics, final Function<Topic, DateTime> dateExtractor) { final DateMidnight startOfToday = new DateMidnight(); final DateMidnight startOfYesterday = startOfToday.minusDays(1); final DateMidnight startOfYear = startOfToday.withDayOfYear(1); return Multimaps.index(topics, new Function<Topic, String>() { @Override/*from w ww. j ava 2s. c om*/ public String apply(Topic input) { DateTime date = dateExtractor.apply(input); if (date.isAfter(startOfToday)) { return "?"; } else if (date.isAfter(startOfYesterday)) { return ""; } else if (date.isAfter(startOfYear)) { return THIS_YEAR_FORMAT.print(date); } else { return OLD_YEAR_FORMAT.print(date); } } }); }