Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

toGMTstring Deprecated to ???

Posted on 2000-04-27
3
Medium Priority
?
2,920 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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

636 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