on 05-14-2009 3:33 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.