简体   繁体   中英

How to convert Angular/Typescript string with date format of 'M/d/yyyy' to Java Date format?

I'm getting an error of

"TypeError: params.title.split is not a function" 

When my date field pass to the rest-api is in the form of '11/30/2019'('M/d/yyyy') , however when I changed the format into "2019-11-30T16:00:00.000+0000" (ISO format) , it works fine.

I'm using Reactive forms in Angular and the data we're pass through formarray

You can convert on the client side with the function formatDate(). See more on https://angular.io/api/common/formatDate

I would suggest use momentJS that have a number of date conversion, calculation and format functions.

momentJS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM