Example usage for org.joda.time LocalDateTime LocalDateTime

List of usage examples for org.joda.time LocalDateTime LocalDateTime

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime LocalDateTime.

Prototype

public LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour,
        int secondOfMinute) 

Source Link

Document

Constructs an instance set to the specified date and time using ISOChronology.

Usage

From source file:nz.co.testamation.testcommon.fixture.SomeFixture.java

License:Apache License

public static LocalDateTime someDateTime() {
    return new LocalDateTime(someYear(), someIntLessThan(12) + 1, someIntLessThan(28) + 1,
            someIntBetween(4, 24), // avoid sometimes invalid 2am due to daylight savings
            someIntLessThan(60), someIntLessThan(60));
}

From source file:org.apache.gobblin.data.management.copy.TimeAwareRecursiveCopyableDataset.java

License:Apache License

private boolean isDatePatternHourly(String datePattern) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
    LocalDateTime refDateTime = new LocalDateTime(2017, 01, 01, 10, 0, 0);
    String refDateTimeString = refDateTime.toString(formatter);
    LocalDateTime refDateTimeAtStartOfDay = refDateTime.withHourOfDay(0);
    String refDateTimeStringAtStartOfDay = refDateTimeAtStartOfDay.toString(formatter);
    return !refDateTimeString.equals(refDateTimeStringAtStartOfDay);
}

From source file:org.apache.isis.core.tck.fixture.scalars.JodaValuedEntityFixture.java

License:Apache License

private JodaValuedEntity createEntity() {
    final JodaValuedEntity jve = jodaValuesEntityRepository.newEntity();
    jve.setLocalDateProperty(new LocalDate(2008, 3, 21));
    jve.setLocalDateTimeProperty(new LocalDateTime(2009, 4, 29, 13, 45, 22));
    jve.setDateTimeProperty(new DateTime(2010, 3, 31, 9, 50, 43, DateTimeZone.UTC));
    return jve;//www .j a v a2 s.  c  o  m
}

From source file:org.apache.isis.objectstore.jdo.datanucleus.Utils.java

License:Apache License

public static long toMillis(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour,
        int secondOfMinute) {
    LocalDateTime d = new LocalDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute);
    return d.toDateTime().getMillis();
}

From source file:org.codehaus.mojo.unix.maven.plugin.Timestamps.java

public FileTimestamp ft(String path, int y, int m, int d, int h, int min, int s) {
    return new FileTimestamp(new File(basedir, path), new LocalDateTime(y, m, d, h, min, s));
}

From source file:org.devgateway.eudevfin.projects.cronjobs.EmailSenderCronService.java

/**
 * Calculates the date in advance with DAYS_IN_ADVANCE. It takes in
 * consideration the year, month and days.
 *
 * @return the future LocalDateTime/*  w  w w  . ja va 2  s  . co m*/
 */
private LocalDateTime getDateAdvanced() {
    Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
    //getTime() returns the current date in default time zone
    Date date = calendar.getTime();
    int currentYear = calendar.get(Calendar.YEAR);
    int currentMonth = calendar.get(Calendar.MONTH) + 1;
    int currentDay = calendar.get(Calendar.DAY_OF_MONTH);

    // Create a calendar object and set year and month
    int daysInMonth = getMaximumDays(currentYear, currentMonth);
    int advancedDays = currentDay + DAYS_IN_ADVANCE;

    if (advancedDays > daysInMonth) {
        if (currentMonth == 12) {
            currentMonth = 0;
            ++currentYear;
        } else {
            ++currentMonth;
        }

        advancedDays -= daysInMonth;
    }

    return new LocalDateTime(currentYear, currentMonth, advancedDays, 0, 0, 0);
}

From source file:org.jpmml.evaluator.FieldValue.java

License:Open Source License

public LocalDateTime asLocalDateTime() {
    Object value = getValue();/*ww  w .ja  v  a 2  s. c  om*/

    if (value instanceof LocalDate) {
        LocalDate instant = (LocalDate) value;

        return new LocalDateTime(instant.getYear(), instant.getMonthOfYear(), instant.getDayOfMonth(), 0, 0, 0);
    } else

    if (value instanceof LocalDateTime) {
        return (LocalDateTime) value;
    }

    throw new TypeCheckException(DataType.DATE_TIME, value);
}

From source file:org.jpmml.evaluator.SecondsSinceDate.java

License:Open Source License

public SecondsSinceDate(LocalDate epoch, LocalDateTime dateTime) {
    setEpoch(epoch);/*from  www.j  ava2 s  .  c o  m*/

    // Have to have the same set of fields
    LocalDateTime epochDateTime = new LocalDateTime(epoch.getYear(), epoch.getMonthOfYear(),
            epoch.getDayOfMonth(), 0, 0, 0);

    setSeconds(Seconds.secondsBetween(epochDateTime, dateTime));
}

From source file:uk.co.onehp.trickle.dao.HibernateBetDaoCustomT.java

License:Open Source License

@Ignore
public static void main(final String[] args) {
    final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "classpath:/spring-trickle.xml");
    final BetDao betDao = (BetDao) applicationContext.getBean("betDao");

    final RaceDao raceDao = (RaceDao) applicationContext.getBean("raceDao");

    final Race race = new Race(867, "Race", new LocalDateTime(2012, 2, 22, 19, 19, 0), "meeting");

    final Horse horse = new Horse();
    horse.setRunnerId(441);/* www . j a  va  2  s.co m*/
    horse.setRaceId(867);

    horse.setRace(race);
    race.addHorse(horse);

    final Strategy strategy1 = new Strategy();
    strategy1.setBetSecondsBeforeStartTime(Lists.newArrayList(120, 270, 600));

    final Strategy strategy2 = new Strategy();
    strategy2.setBetSecondsBeforeStartTime(Lists.newArrayList(120, 270, 700));

    raceDao.saveOrUpdate(race);

    final Bet bet1 = new Bet(horse, strategy1);
    betDao.saveOrUpdate(bet1);

    final Bet bet2 = new Bet(horse, strategy2);
    betDao.saveOrUpdate(bet2);

    System.out.println(betDao.getBetsToPlace());
}

From source file:uk.co.onehp.trickle.util.DateUtil.java

License:Open Source License

public static LocalDateTime gregorianCalendarToLocalDateTime(XMLGregorianCalendar calendar) {
    return new LocalDateTime(calendar.getYear(), calendar.getMonth(), calendar.getDay(), calendar.getHour(),
            calendar.getMinute(), calendar.getSecond());
}