?
Solved

toGMTstring Deprecated to ???

Posted on 2000-04-27
3
Medium Priority
?
2,737 Views
Last Modified: 2008-03-17
Hi all,

   In an applet, I was using this toGMTstring method, but for some reasons I needed to re-compile this applet, but this time with this new jdk1.3 and it gives all the errrors in the world to me.
   So the problem is :

   How to get the GMT time for the local Time ?

0
Comment
Question by:clique10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:dmaguillo
ID: 2755453
Hi clique 10.

U must replace it by:

DateFormat.format(Date date)

Bye... :)
0
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 596 total points
ID: 2756316
Specifically, if you currently have:

    import java.util.Date;
    ...
    Date date = new Date();
    String gmt = date.toGMTstring();

replace it with the following:

    import java.util.Date;
    import java.util.TimeZone;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    ...
    Date date = new Date();
    DateFormat df = new SimpleDateFormat("dd MMM yyyy kk:mm:ss z");
    df.setTimeZone(TimeZone.getTimeZone("GMT"));
    String gmt = df.format(date);

The String result in gmt will be _exactly_ the same as that previously generated by the Date.toGMTstring method.

Date still represents a specific instant in time, with millisecond precision. Prior to JDK 1.1, the class allowed the interpretation of dates as year, month, day, hour, minute, and second values, and the formatting and parsing of date strings. Unfortunately, the API for these functions was not amenable to internationalization. As of JDK 1.1, the Calendar class should be used to convert between dates and time fields and the DateFormat class should be used to format and parse date strings. The corresponding methods in Date are deprecated.

Best regards,
Jim Cakalic
0
 

Author Comment

by:clique10
ID: 2770465
Thanks Jim !!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question