cancel
Showing results for 
Search instead for 
Did you mean: 

How to get IST time

former_member213558
Active Participant
0 Kudos

Dear All.

i'm using an expression ${date:now:yyyyMMdd 'at' hhmmss z} to get the date,time and the time zone.

the result i'm getting is 20170201 at 101744 GMT .

how can i get the IST time zone?

can you please suggest.

Regards

Ramesh

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor

Hello Ramesh,

Below will help you to convert the time to IST.

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.text.SimpleDateFormat;
import java.util.Date;

def Message processData(Message message) {

    def body = message.getBody();
    
    //Get current Date and Time.
    def currentUTCTime = new Date()
    
    //Declare a empty string to hold the Converted Time        
    def convertedISTTime='';
    
    //Convert and format it into required IST format
    convertedISTTime=currentUTCTime.format("yyyyMMdd ' at 'HH:mm:ss XXX", TimeZone.getTimeZone('IST'))
    
    //Set Property for your future use in integration process
    message.setProperty("P_CurrentISTTime", convertedISTTime );
    
    //Set the value to your Body if required.
    message.setBody(convertedISTTime);

return message;
}

Regards,

Sriprasad Shivaram Bhat

former_member213558
Active Participant

Dear Sri.

Great Again.

first i would like to appreciate your contribution in SCN, thank you so much you contribution in in HCI space.

it's working fine.

Reagrds

Ramesh

0 Kudos

Hi Sri,

How can we convert time from IST to UTC timezone? In fact, for all the conversions, what time zone does the system considers as a source timezone.

In the above example, def currentUTCTime = new Date() , this line gives time in UTC time zone.

But , if my source time is in different time zone(Other than UTC) then, how can I convert this to UTC timezone.

Regards,

Santosh Pathuri


Answers (3)

Answers (3)

former_member213558
Active Participant
0 Kudos

Can any one has the script for the same.

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Ramesh,

I have tried the above case and seems its not possible to change it using expressions only.

You can use the script and get the time Converted to IST.

Regards,

Sriprasad Shivaram Bhat

former_member213558
Active Participant
0 Kudos

Hi Sri.

Thanks for your time to check this option at your end.

Regards

Ramesh

Former Member
0 Kudos

Ramesh,

Where do u use this expression?

former_member213558
Active Participant
0 Kudos

Hi Jasirrani.

i'm using this in my content container and the same content to be call to mail adapter's body by using ${body} expression.

Regards

Ramesh