How to create an Instant field for a date field using formik and material ui?

Viewed 23

Hi I am creating a form using materialUI and formik. I am trying to create a Date field using TextField component that gives me back an Instant rather than a LocalDate.

The code for that field is provided below:

<Grid item xs={12} sm={12}>
 <Field
  name='Date'
  label='Date'
  type="date"
  component={TextField}
 />
</Grid>

I tried type="date" and type="datetime-local" and I am getting this error:

JSON parse error: Cannot deserialize value of type java.time.Instant from String "2022-08-23": Failed to deserialize java.time.Instant: (java.time.format.DateTimeParseException) Text '2022-08-23' could not be parsed at index 10; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize

On the materialUI website it said that type should be a valid html5 input type.

https://v4.mui.com/api/text-field/

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types

What other valid input type are there that can give me an Instant??

0 Answers
Related