1

The below code works fine within a mule xml transformer

<xml:context-property key="myRecordCreateTimeStamp" value="#[server.dateTime.withTimeZone('GMT').format('MM/dd/yyyyHH:mm:ss')]"/>

If I want to achieve the same thing in a Java class inside a Mule ESB project, which classes should I implement? And what is the equivalent class inside MuleEvent object?

Ale Sequeira
  • 2,039
  • 1
  • 11
  • 19
Pavan JHNR
  • 49
  • 1
  • 11

1 Answers1

1

I would suggest using Joda Time in java component to do this.

Use Imports

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;

Example

    DateTimeFormatter parser = DateTimeFormat.forPattern( "MM/dd/yyyyHH:mm:ss" ).withZone(DateTimeZone.UTC);
    DateTime dateTime = new DateTime(new Date());
    String gmtDateString = parser.print(dateTime);
Joe Scaria
  • 125
  • 1
  • 9