Looking for a LocalDateTime converter

I’m fairly new to Spring Boot and Vaadin, and trying to build a little project.
I followed the tutorials on the vaadin website and watched the videos, but ran into a conversion problem.
I’m saving a “createdAt” value in the database with the type of “LocalDateTime”.
But when I want to display the value into a Textfield, vaadin throws me the error LocalDateTime cannot be resolved in a string textfield. With the hint, that I should manage the conversion and bindings of the fields manually.

Now my question: How do I convert a LocalDateTime to String in Vaadin?
My solution was this:

            .withConverter(
                LocalDateTime -> LocalDateTime.toString()
            )
            .bind("createdAt");```

Why does this not work?
Thanks for any help or hints.

I would suggest to use DateTimePicker instead of TextField. Better UX and DX (no need for convertors).

And the answer to your question :slightly_smiling_face: :

    TextField ldt = new TextField("Local Date Time");;

    public static class Dto {
        LocalDateTime ldt = LocalDateTime.now();

        public LocalDateTime getLdt() {
            return ldt;
        }

        public void setLdt(LocalDateTime ldt) {
            this.ldt = ldt;
            System.out.println("setLdt: " + ldt);
        }
    }

    public MainView() {
        Binder<Dto> dtoBinder = new Binder<>(Dto.class);
        dtoBinder.forMemberField(ldt).withConverter(
                s -> LocalDateTime.parse(s),
                m -> m.toString()
        );
        dtoBinder.bindInstanceFields(this);
        dtoBinder.setBean(new Dto());

        add(ldt);


Thanks alot for this quick solution. It works like a charm.