Solved

toGMTstring Deprecated to ???

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now