Solved

toGMTstring Deprecated to ???

Posted on 2000-04-27
3
2,506 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 149 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

Suggested Solutions

Title # Comments Views Activity
hibernate example for saving data 19 107
Crystal Reports Licensing Questions 4 81
netbeans can not run self signed app 8 36
Read CLOB data from Oracle using JAVA 3 37
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

739 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