0

I have a reservation site that uses an Angular datepicker to select the date, the date is then put into sessionStorage, then parsed (in the cart), and then sent to the database. In the database, the dates look like:

2021-07-03 06:00:00
2021-06-20 05:00:00

Through out the process, everything has the type of Date front end and backend.

The problem is I need to check stock when the next person makes a reservation. So I have the following method:

 console.log(this.date); // Sat Jul 03 2021 00:00:00 GMT-0500 (Central Daylight Time)
      
      this.api.getAllOrdersByDate(this.date).subscribe((res)=>{
        console.log(res); // []

but since this date hasn't gone through the sessionStorage/database, it is still in Datepicker format and therefore my method comes back with an empty array.

What do I need to do to get the formats to match?

Thanks!!

AylaWinters
  • 1,121
  • 2
  • 7
  • 24
  • does this help https://stackoverflow.com/questions/18480633/java-util-date-format-conversion-yyyy-mm-dd-to-mm-dd-yyyy – newbie Jun 30 '21 at 14:57
  • @newbie, It gives some ideas, but it shows how to change the format for a sys out not how to change the format of the actual date. So it wouldn't change how it looks in the database if I'm reading all this right? – AylaWinters Jun 30 '21 at 15:05
  • 1
    `this.date` appears to just be a JavaScript Date object. You appear to be passing that to the Java API, which should receive it as a Java Date object. Is this not the case? Do you want to format the date on the front end or the API? – daddygames Jun 30 '21 at 15:40

0 Answers0