0

I have the following code in my jsp. I use JSTL ${scheduledRideEndTime} to retrieve the data.

<script>
    var timeto2 = ${scheduledRideEndTime};
    var hours3 = moment(timeto2).format("hh:mm a")
    document.write(hours3);
</script>

If I hit Control Shift F on eclipse the formatting changes to

 <script>
    var timeto2 = $
    {
         scheduledRideEndTime
    };
    var hours3 = moment(timeto2).format("hh:mm a")
    document.write(hours3);
</script>

I then get syntax errors in my view. If I redo the code to "${scheduledRideEndTime}"; the Control Shift F does not reformat the code, but view prints Invalid date.

What am I missing here ? I want to be able to reformat code.

3
  • maybe try to wrap it in single quotes? '${scheduledRideEndTime}' Commented Aug 29, 2017 at 7:13
  • i think not the best way but , load the value in dom or some hidden field like $("#abc").val("${scheduledRideEndTime}") and then get the value next time , i have done something like this before $("#voucherNumber").val( "${sessionScope.abc}"); and get it Commented Aug 29, 2017 at 12:18
  • @JapanGuy single quotes did not work either. Commented Sep 6, 2017 at 4:07

1 Answer 1

1

Try this:

<script>
    var timeto2 = parseInt("${scheduledRideEndTime}");
    var hours3 = moment(timeto2).format("hh:mm a")
    document.write(hours3);
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.