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, int millisOfSecond, Chronology chronology) 

Source Link

Document

Constructs an instance set to the specified date and time using the specified chronology, whose zone is ignored.

Usage

From source file:com.helger.datetime.PDTFactory.java

License:Apache License

@Nonnull
public static LocalDateTime createLocalDateTime(final int nYears, final int nMonths, final int nDays,
        final int nHours, final int nMinutes, final int nSeconds, final int nMilliSeconds) {
    // Always using UTC internally!
    return new LocalDateTime(nYears, nMonths, nDays, nHours, nMinutes, nSeconds, nMilliSeconds,
            getLocalChronology());//from  w  w  w.  ja  v  a  2 s  .c  om
}

From source file:de.javakaffee.kryoserializers.jodatime.JodaLocalDateTimeSerializer.java

License:Apache License

@Override
public LocalDateTime read(Kryo kryo, Input input, Class<LocalDateTime> type) {
    final long packedLocalDateTime = input.readLong(true);
    final int packedYearMonthDay = (int) (packedLocalDateTime / 86400000);
    final int millisOfDay = (int) (packedLocalDateTime % 86400000);
    final Chronology chronology = IdentifiableChronology.readChronology(input);
    return new LocalDateTime(packedYearMonthDay / (13 * 32), (packedYearMonthDay % (13 * 32)) / 32,
            packedYearMonthDay % 32, millisOfDay / 3600000, (millisOfDay % 3600000) / 60000,
            (millisOfDay % 60000) / 1000, millisOfDay % 1000, chronology);
}

From source file:name.martingeisse.wicket.panel.simple.DateTimeTextFieldPanel.java

License:Open Source License

@Override
protected void convertInput() {

    // get all required objects. Note: This method is invoked *before* the sub-text-fields
    // have stored their model values in this object, so we must get them manually.
    final Class<?> modelType = getType();
    final LocalDate date = getDateTextField().getConvertedInput();
    final LocalTime time = getTimeTextField().getConvertedInput();

    // convert the input
    if (modelType == DateTime.class) {
        final DateTime localizedDateTime = new DateTime(date.getYear(), date.getMonthOfYear(),
                date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(),
                time.getMillisOfSecond(), localizedChronology);
        setConvertedInputUnsafe(localizedDateTime.withChronology(originalChronology));
    } else if (modelType == LocalDateTime.class) {
        setConvertedInputUnsafe(new LocalDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
                time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(),
                localizedChronology));//w w  w . ja  va  2 s  .co m
    } else {
        throw new IllegalStateException("unsupported model type for DateTimeTextFieldPanel: " + modelType);
    }

}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.TimeColumnLocalTimeMapper.java

License:Apache License

@Override
public Time toNonNullValue(LocalTime value) {

    DateTime zonedValue = new LocalDateTime(1970, 1, 1, value.getHourOfDay(), value.getMinuteOfHour(),
            value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology()).toDateTime();

    final Time time = new Time(zonedValue.getMillis());
    return time;//  ww  w.j ava 2 s .  c  o  m
}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.TimeColumnTimeOfDayMapper.java

License:Apache License

@Override
public Time toNonNullValue(TimeOfDay value) {

    DateTime zonedValue = new LocalDateTime(1970, 1, 1, value.getHourOfDay(), value.getMinuteOfHour(),
            value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology()).toDateTime();

    final Time time = new Time(zonedValue.getMillis());
    return time;//from   ww  w. jav  a2s.  co  m
}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.TimestampColumnLocalTimeMapper.java

License:Apache License

@Override
public Timestamp toNonNullValue(LocalTime value) {

    DateTime zonedValue = new LocalDateTime(1970, 1, 1, value.getHourOfDay(), value.getMinuteOfHour(),
            value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology()).toDateTime();

    final Timestamp timestamp = new Timestamp(zonedValue.getMillis());
    return timestamp;
}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.TimestampColumnTimeOfDayMapper.java

License:Apache License

@Override
public Timestamp toNonNullValue(TimeOfDay value) {

    DateTime zonedValue = new LocalDateTime(1970, 1, 1, value.getHourOfDay(), value.getMinuteOfHour(),
            value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology()).toDateTime();

    final Timestamp timestamp = new Timestamp(zonedValue.getMillis());
    return timestamp;
}

From source file:org.odk.collect.android.fragments.dialogs.CopticDatePickerDialog.java

License:Apache License

private LocalDateTime getCurrentCopticDate() {
    int copticDay = getDay();
    int copticMonth = Arrays.asList(monthsArray).indexOf(getMonth());
    int copticYear = getYear();

    LocalDateTime copticDate = new LocalDateTime(copticYear, copticMonth + 1, 1, 0, 0, 0, 0,
            CopticChronology.getInstance());
    if (copticDay > copticDate.dayOfMonth().getMaximumValue()) {
        copticDay = copticDate.dayOfMonth().getMaximumValue();
    }/* ww  w .  j a v  a 2 s .c o  m*/

    return new LocalDateTime(copticYear, copticMonth + 1, copticDay, 0, 0, 0, 0,
            CopticChronology.getInstance());
}

From source file:org.odk.collect.android.fragments.dialogs.EthiopianDatePickerDialog.java

License:Apache License

private LocalDateTime getCurrentEthiopianDate() {
    int ethiopianDay = getDay();
    int ethiopianMonth = Arrays.asList(monthsArray).indexOf(getMonth());
    int ethiopianYear = getYear();

    LocalDateTime ethiopianDate = new LocalDateTime(ethiopianYear, ethiopianMonth + 1, 1, 0, 0, 0, 0,
            EthiopicChronology.getInstance());
    if (ethiopianDay > ethiopianDate.dayOfMonth().getMaximumValue()) {
        ethiopianDay = ethiopianDate.dayOfMonth().getMaximumValue();
    }// ww w  .j av a  2  s.co m

    return new LocalDateTime(ethiopianYear, ethiopianMonth + 1, ethiopianDay, 0, 0, 0, 0,
            EthiopicChronology.getInstance());
}

From source file:org.odk.collect.android.fragments.dialogs.IslamicDatePickerDialog.java

License:Apache License

private LocalDateTime getCurrentIslamicDate() {
    int islamicDay = getDay();
    int islamicMonth = Arrays.asList(monthsArray).indexOf(getMonth());
    int islamicYear = getYear();

    LocalDateTime islamicDate = new LocalDateTime(islamicYear, islamicMonth + 1, 1, 0, 0, 0, 0,
            IslamicChronology.getInstance());
    if (islamicDay > islamicDate.dayOfMonth().getMaximumValue()) {
        islamicDay = islamicDate.dayOfMonth().getMaximumValue();
    }//from ww w  .  j a v a  2s  .com

    return new LocalDateTime(islamicYear, islamicMonth + 1, islamicDay, 0, 0, 0, 0,
            IslamicChronology.getInstance());
}