|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
java.lang.String ClassThe following constructors and methods injava.lang.Stringwere deprecated in favor of their replacements which better support internationalization. These constructors and methods did not properly convert bytes into characters. The new constructors and methods use a named character-encoding or the default character-encoding to do the conversion.
Deprecated Methods Alternatives String(byte[], int)String(byte[]) or String(byte[], String)String(byte[], int, int, int)String(byte[], int, int) or String(byte[], int, int, String)getBytes(int, int, byte[], int)byte[] getBytes(String)orbyte[] getBytes()Characters and Strings
covers the
Stringclass thorougly.
java.lang.System ClassThegetenvmethod has been out of use for several releases of the JDK. The 1.1 release formalizes this change by deprecating the method. Programmers should usePropertiesto store information between invocations of a program.
Deprecated Methods Alternatives String getenv(String)String getProperty(String)Using Properties to Manage Program Attributes
talks about how to use the
Propertiesclass and our online trail Isolating Locale-Specific Datashows you how to use
Propertiesto help internationalize your Java programs.
java.lang.Runtime ClassThe following methods in thejava.lang.Runtimeclass have been deprecated because the JDK 1.1 introduced new internationalization features that replaced them. The new internationalization API includes I/O classes that translate a byte stream into a character stream based on a character-encoding.
Deprecated Methods Alternatives InputStream getLocalizedInputStream(InputStream)InputStreamReaderor
BufferedReaderclasses
OutputStream getLocalizedOutputStream(OutputStream)OutputStreamWriteror
BufferedWriteror
PrintWriterclasses
You can learn more about the
Runtimeclass in: The Runtime Object.
java.lang.Character ClassThe following methods in thejava.lang.Characterclass were deprecated in favor of their alternativies which better support internationalization.
Deprecated Methods Alternatives boolean isJavaLetter(char)boolean isJavaIdentifierStart(char)boolean isJavaLetterOrDigit(char)boolean isJavaIdentifierPart(char)boolean isSpace(char)boolean isWhitespace(char)The tutorial does not cover this class.
java.lang.ClassLoader ClassThe following method injava.lang.ClassLoaderhas been deprecated in favor of the version that takes aStringas a first argument because the latter is more secure.
Deprecated Methods Alternatives Class defineClass(byte[], int, int)Class defineClass(String, byte[], int, int)The tutorial does not cover this class.
java.net.Socket ClassTwo constructors in thejava.net.Socketclass were deprecated. These constructors allowed programmers to create aDatagramSocket. Now programmers should explicitly construct aDatagramSocketif they want one.
Deprecated Methods Alternatives Socket(InetAddress, int, boolean)One of DatagramSocket's three constructorsSocket(String, int, boolean)One of DatagramSocket's three constructorsYou can learn about
SocketandDatagramSocketin All About Socketsand All About Datagrams
, respectively.
java.util.Date ClassMany of the methods injava.util.Datehave been deprecated in favor of other APIs that better support internationalization. The following table provides a list of these methods and their alternatives.
Deprecated Methods Alternatives Date(int, int, int),
Date(int, int, int, int),
Date(int, int, int, int, int, int), and
Date(String)Create a .java.util.GregorianCalendarobject and use itsgetTimemethod to convert it to aDateint getYear(),
int getMonth(),
int getDate(),
int getHours(),
int getMinutes(),
int getSeconds(),
int getDay(),
int getTimezoneOffset(),
setYear(int),
setMonth(int),
setDate(int),
setHours(int),
setMinutes(int),
setSeconds(int), and
UTC(int, int, int, int, int, int)Create a java.util.GregorianCalendarobject and use its setters and getters instead.parse(String),
String toLocaleString(), and
String toGMTString()Use java.text.DateFormatand its subclasses to parse and format dates.Instinctively, when programmers want to create the current date, they immediately look at the
Dateclass. While intuitive, this is usually the wrong choice. For storing date and time information, most programmers should use theCalendarclass, and to format dates and times they should use thejava.text.DateFormatclass. This is all described with task-oriented documentation and examples in Internationalization.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.