cancel
Showing results for 
Search instead for 
Did you mean: 

Time Zone conversion EST to GMT..

former_member238007
Contributor
0 Kudos

Hi Experts,

I want an UDF for converting the time Zone conversion, such from EST to UTC/GMT.

How Can we handle this?

I am getting the input only time as 12:34:45 i need to convert this EST to GMT.

when i search i found an UDF based on the date validation only..

Date date = new Date();

DateFormat estFormat = new SimpleDateFormat();

DateFormat gmtFormat = new SimpleDateFormat();

TimeZone gmtTime = TimeZone.getTimeZone("GMT");

TimeZone estTime = TimeZone.getTimeZone("EST");

estFormat.setTimeZone(gmtTime);

gmtFormat.setTimeZone(estTime);

System.out.println("GMT Time: " + estFormat.format(date));

System.out.println("EST Time: " + gmtFormat.format(date));

any help will be really appreciated..

regards,

Kishore

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

import java.util.Date;

import java.text.SimpleDateFormat;

import java.text.DateFormat;

import java.util.TimeZone;

public class ConvertTimeZone {

public static void main(String[] args) {

Date date = new Date();

DateFormat firstFormat = new SimpleDateFormat();

DateFormat secondFormat = new SimpleDateFormat();

TimeZone firstTime = TimeZone.getTimeZone(args[0]);

TimeZone secondTime = TimeZone.getTimeZone(args[1]);

firstFormat.setTimeZone(firstTime);

secondFormat.setTimeZone(secondTime);

System.out.println("-->"args[0]": " + firstFormat.format(date));

System.out.println("-->"args[1]": " + secondFormat.format(date));

}

}

Please check with this. The code is from the link:

http://www.roseindia.net/java/javadate/converting-time-time-zone.shtml

Regards,

Vineetha

Answers (1)

Answers (1)

Shabarish_Nair
Active Contributor
0 Kudos
Date date = new Date();
	    DateFormat estFormat = new SimpleDateFormat();
	    DateFormat gmtFormat = new SimpleDateFormat();
	    TimeZone gmtTime = TimeZone.getTimeZone("GMT");
	    TimeZone estTime = TimeZone.getTimeZone("EST");
	    estFormat.setTimeZone(gmtTime);
	    gmtFormat.setTimeZone(estTime);
	   // System.out.println("GMT Time: " + estFormat.format(date));
	    //System.out.println("EST Time: " + gmtFormat.format(date));

doesnt this work?

what is the issue you are facing? the above code will give you the current date and time in EST and GMT formats

former_member238007
Contributor
0 Kudos

Hi..

I will be getting the input only the time but not with the date, so,i am confusing to how to handle that..

regards,

Kishore