Skip to content

Instantly share code, notes, and snippets.

@raugustinus
Last active May 20, 2016 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raugustinus/8d5579367cbeb895c81f to your computer and use it in GitHub Desktop.
Save raugustinus/8d5579367cbeb895c81f to your computer and use it in GitHub Desktop.
wicket TimeField supporting the <input type="time" .../> attribute
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.joda.time.LocalTime;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
public class TimeField extends TextField<LocalTime> {
private static final Logger LOG = getLogger(TimeField.class);
public TimeField(String id, IModel<LocalTime> model) {
super(id, model);
}
@Override
protected String getInputType() {
return "time";
}
@Override
protected void convertInput() {
super.convertInput();
String input = getInput();
LOG.debug("convering input: {}", input);
LocalTime result = LocalTime.parse(input);
LOG.debug("result: {}", result);
setConvertedInput(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment