String to Date conversion

Asked

Viewed 60 times

2

I have html form with the following input:

<div class="form-group">
    <label class="col-md-4 control-label" for="textinput">Início:</label>
    <div class="col-md-4">
        <input id="inicioEvento" name="inicioEvento" class="form-control input-md" type="datetime-local">
    </div>
</div>

My problem is to convert the result of formMap.get("startEvent"), which returns a String and converts to the Date type, since in the Event class, the start attribute is of the Date type, then setInicio(Date start).

P.S.: I’m a beginner.

  • Java or javascript? Not the same thing, despite similar names.

1 answer

0

You can convert a string to date like this:

new Date('2011-04-11')

for more information: MDN|Date

Browser other questions tagged

You are not signed in. Login or sign up in order to post.