Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
java.lang.String
ClassThe following constructors and methods injava.lang.String
were 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
String
class thorougly.
java.lang.System
ClassThegetenv
method has been out of use for several releases of the JDK. The 1.1 release formalizes this change by deprecating the method. Programmers should useProperties
to 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
Properties
class and our online trail Isolating Locale-Specific Data shows you how to useProperties
to help internationalize your Java programs.
java.lang.Runtime
ClassThe following methods in thejava.lang.Runtime
class 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)
InputStreamReader
orBufferedReader
classesOutputStream getLocalizedOutputStream(OutputStream)
OutputStreamWriter
orBufferedWriter
orPrintWriter
classesYou can learn more about the
Runtime
class in: The Runtime Object.
java.lang.Character
ClassThe following methods in thejava.lang.Character
class 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.ClassLoader
has been deprecated in favor of the version that takes aString
as 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.Socket
class were deprecated. These constructors allowed programmers to create aDatagramSocket
. Now programmers should explicitly construct aDatagramSocket
if 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
Socket
andDatagramSocket
in All About Sockets and All About Datagrams, respectively.
java.util.Date
ClassMany of the methods injava.util.Date
have 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.GregorianCalendar
object and use itsgetTime
method to convert it to aDate
int 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.GregorianCalendar
object and use its setters and getters instead.parse(String)
,
String toLocaleString()
, and
String toGMTString()
Use java.text.DateFormat
and its subclasses to parse and format dates.Instinctively, when programmers want to create the current date, they immediately look at the
Date
class. While intuitive, this is usually the wrong choice. For storing date and time information, most programmers should use theCalendar
class, and to format dates and times they should use thejava.text.DateFormat
class. 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-2002 Sun Microsystems, Inc. All rights reserved.