use of java.time.LocalTime in project wildfly by wildfly.
the class LocalDateTimeExternalizer method readObject.
@Override
public LocalDateTime readObject(ObjectInput input) throws IOException, ClassNotFoundException {
LocalDate date = DATE_EXTERNALIZER.readObject(input);
LocalTime time = TIME_EXTERNALIZER.readObject(input);
return LocalDateTime.of(date, time);
}
use of java.time.LocalTime in project felix by apache.
the class ConverterTest method testLocalTime.
@Test
public void testLocalTime() {
LocalTime lt = LocalTime.now();
String s = converter.convert(lt).to(String.class);
assertTrue(s.length() > 0);
LocalTime lt2 = converter.convert(s).to(LocalTime.class);
assertEquals(lt, lt2);
}
use of java.time.LocalTime in project dbflute-core by dbflute.
the class AbstractConditionQuery method filterConditionValueIfNeeds.
protected Object filterConditionValueIfNeeds(ConditionKey key, Object value, ConditionValue cvalue, String columnDbName, ConditionOption option, ColumnInfo columnInfo) {
if (value != null && isDatetimePrecisionTruncationOfConditionEnabled(columnDbName)) {
// null check, just in case
if (columnInfo.isObjectNativeTypeDate()) {
// contains Java8 Dates
final Integer datetimePrecision = columnInfo.getDatetimePrecision();
if (datetimePrecision == null || datetimePrecision == 0) {
// non-millisecond date-time
if (value instanceof LocalDateTime) {
// means clear millisecond
return ((LocalDateTime) value).truncatedTo(ChronoUnit.SECONDS);
} else if (value instanceof LocalTime) {
// means clear millisecond
return ((LocalTime) value).truncatedTo(ChronoUnit.SECONDS);
} else if (value instanceof Date && !(value instanceof java.sql.Date)) {
final Calendar cal = DfTypeUtil.toCalendar(value);
DfTypeUtil.clearCalendarMillisecond(cal);
return DfTypeUtil.toDate(cal);
}
}
}
}
return value;
}
use of java.time.LocalTime in project jphp by jphp-compiler.
the class UXMaterialTimePicker method getValueAsTime.
@Getter
public WrapTime getValueAsTime(Environment env) {
initFormat();
LocalTime value = getWrappedObject().getValue();
if (value == null) {
return null;
}
Instant instant = value.atDate(LocalDate.of(0, 0, 0)).atZone(ZoneId.systemDefault()).toInstant();
return new WrapTime(env, Date.from(instant));
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class Parsed method resolveFields.
//-----------------------------------------------------------------------
private void resolveFields() {
// resolve ChronoField
resolveInstantFields();
resolveDateFields();
resolveTimeFields();
// any lenient date resolution should return epoch-day
if (fieldValues.size() > 0) {
int changedCount = 0;
outer: while (changedCount < 50) {
for (Map.Entry<TemporalField, Long> entry : fieldValues.entrySet()) {
TemporalField targetField = entry.getKey();
TemporalAccessor resolvedObject = targetField.resolve(fieldValues, this, resolverStyle);
if (resolvedObject != null) {
if (resolvedObject instanceof ChronoZonedDateTime) {
ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime<?>) resolvedObject;
if (zone == null) {
zone = czdt.getZone();
} else if (zone.equals(czdt.getZone()) == false) {
throw new DateTimeException("ChronoZonedDateTime must use the effective parsed zone: " + zone);
}
resolvedObject = czdt.toLocalDateTime();
}
if (resolvedObject instanceof ChronoLocalDateTime) {
ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime<?>) resolvedObject;
updateCheckConflict(cldt.toLocalTime(), Period.ZERO);
updateCheckConflict(cldt.toLocalDate());
changedCount++;
// have to restart to avoid concurrent modification
continue outer;
}
if (resolvedObject instanceof ChronoLocalDate) {
updateCheckConflict((ChronoLocalDate) resolvedObject);
changedCount++;
// have to restart to avoid concurrent modification
continue outer;
}
if (resolvedObject instanceof LocalTime) {
updateCheckConflict((LocalTime) resolvedObject, Period.ZERO);
changedCount++;
// have to restart to avoid concurrent modification
continue outer;
}
throw new DateTimeException("Method resolve() can only return ChronoZonedDateTime, " + "ChronoLocalDateTime, ChronoLocalDate or LocalTime");
} else if (fieldValues.containsKey(targetField) == false) {
changedCount++;
// have to restart to avoid concurrent modification
continue outer;
}
}
break;
}
if (changedCount == 50) {
// catch infinite loops
throw new DateTimeException("One of the parsed fields has an incorrectly implemented resolve method");
}
// if something changed then have to redo ChronoField resolve
if (changedCount > 0) {
resolveInstantFields();
resolveDateFields();
resolveTimeFields();
}
}
}
Aggregations