简体   繁体   中英

Mule data mapping date time conversion not showing hours

I have a date value of 2016-04-06-06:00 coming from one system and I need to map it to a string field.

I'm trying to use output.DateStr = date2str(input.myDate,"yyyy-MM-dd-hh:mm"); in the data mapping script but the DateStr field shows 2016-04-06-12:00

I have also tried "yyyy-MM-dd-HH:mm" but this comes through as 2016-04-06-00:00

Does anyone know how I can fix this?

try somtehing like :

DateFormat df = new SimpleDateFormat("yyyy-MM-/dd-HH:mm");

//DateFormat format method create a string 

String reportDate = df.format(yourDate);

I hope it helps.

Try this:

#[dateString = new java.util.Date().toString();
  payload = new org.mule.el.datetime.DateTime(dateString, 'yyyy-MM-dd-hh:mm');]

change dateString as '2016-04-06-06:00'.

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