001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.extensions.markup.html.form.datetime; 018 019import java.time.LocalDate; 020import java.time.LocalDateTime; 021import java.time.LocalTime; 022 023import org.apache.wicket.model.IModel; 024 025/** 026 * Works on a {@link java.time.LocalDateTime} object. See {@link AbstractDateTimeField} for 027 * further details. 028 * 029 * @author eelcohillenius 030 */ 031public class LocalDateTimeField extends AbstractDateTimeField<LocalDateTime> 032{ 033 private static final long serialVersionUID = 1L; 034 035 /** 036 * Construct. 037 * 038 * @param id 039 */ 040 public LocalDateTimeField(final String id) 041 { 042 this(id, null); 043 } 044 045 /** 046 * Construct. 047 * 048 * @param id 049 * @param model 050 */ 051 public LocalDateTimeField(final String id, final IModel<LocalDateTime> model) 052 { 053 super(id, model); 054 055 // Sets the type that will be used when updating the model for this component. 056 setType(LocalDateTime.class); 057 } 058 059 @Override 060 protected LocalDateTime createTemporal(LocalDate date, LocalTime time) { 061 return LocalDateTime.of(date, time); 062 } 063 064 @Override 065 protected LocalDate getLocalDate(LocalDateTime temporal) 066 { 067 return temporal.toLocalDate(); 068 } 069 070 @Override 071 protected LocalTime getLocalTime(LocalDateTime temporal) 072 { 073 return temporal.toLocalTime(); 074 } 075}