Example usage for org.joda.time ReadablePartial toDateTime

List of usage examples for org.joda.time ReadablePartial toDateTime

Introduction

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

Prototype

DateTime toDateTime(ReadableInstant baseInstant);

Source Link

Document

Converts this partial to a full datetime by resolving it against another datetime.

Usage

From source file:org.hibernate.validator.constraints.impl.FutureValidatorForReadablePartial.java

License:Apache License

public boolean isValid(ReadablePartial value, ConstraintValidatorContext context) {
    //null values are valid
    if (value == null) {
        return true;
    }/*from w  w w.j  av  a  2 s. com*/

    return value.toDateTime(null).isAfterNow();
}

From source file:org.hibernate.validator.constraints.impl.PastValidatorForReadablePartial.java

License:Apache License

public boolean isValid(ReadablePartial value, ConstraintValidatorContext context) {
    //null values are valid
    if (value == null) {
        return true;
    }//from  www. j a v  a  2s  .  co m

    return value.toDateTime(null).isBeforeNow();
}

From source file:org.hibernate.validator.internal.constraintvalidators.bv.future.FutureValidatorForReadablePartial.java

License:Apache License

@Override
public boolean isValid(ReadablePartial value, ConstraintValidatorContext context) {
    //null values are valid
    if (value == null) {
        return true;
    }/*from  w  ww.  j  a v a 2  s  .  com*/

    TimeProvider timeProvider = context.unwrap(HibernateConstraintValidatorContext.class).getTimeProvider();
    long now = timeProvider.getCurrentTime();

    return value.toDateTime(new Instant(now)).isAfter(now);
}

From source file:org.hibernate.validator.internal.constraintvalidators.bv.past.PastValidatorForReadablePartial.java

License:Apache License

@Override
public boolean isValid(ReadablePartial value, ConstraintValidatorContext context) {
    //null values are valid
    if (value == null) {
        return true;
    }//from  w  w w . ja v a 2 s  . com

    TimeProvider timeProvider = context.unwrap(HibernateConstraintValidatorContext.class).getTimeProvider();
    long now = timeProvider.getCurrentTime();

    return value.toDateTime(new Instant(now)).isBefore(now);
}

From source file:org.hibernate.validator.internal.constraintvalidators.bv.time.future.FutureValidatorForReadablePartial.java

License:Apache License

@Override
protected long getEpochMillis(ReadablePartial value, Clock reference) {
    return value.toDateTime(new Instant(reference.millis())).getMillis();
}

From source file:org.netxilia.api.value.DateValue.java

License:Open Source License

@Override
public int compareTo(IGenericValue value) {
    if (value == null) {
        return 1;
    }//from   w  w  w.  j a v  a2  s  . c  o  m
    ReadablePartial other = value.getDateValue();
    if (other == null) {
        if (this.value == null) {
            return 0;
        }
        return 1;
    }
    return this.value.toDateTime(ORIGIN).compareTo(other.toDateTime(ORIGIN));
}