Category Archive for: java.util More Utility Classes

java .util Part 2 More Utility Classes

java .util Part 2 More Utility Classes ThiS chapter continues our discussion of java.util by examining those classes and interfaces that are not part of the collections framework. These include classes that tokenize strings, work with dates, compute random numbers, and observe . events. Also, the java.util.ztp and java.util.jar packages are briefly mentioned at the end of this chapter JavaHelpOnline.comInstructions Feel…

Read More →

Observable

Observable  The db~variable class is used to create sub classes that other parts of your program can observe. When an object of such a subclass undergoes a change, observing classes are ‘ notified. Observing classes must implement the Observer interface, which defines the antedate ) method. The update( ) method is called when an observer is notified of…

Read More →

Random

Random The Random class is a generator of pseudo random numbers. These are called pseudo random,numbers because they are simply uniformly distributed sequences. Random defines the following constructors:  Random() Random Long seed) The first version creates number generator that uses the current time as the starting, or seed, value. The second form allows you to specify a seed value manually.…

Read More →

Locale

Locale  The Locale class is instantiated to produce objects that each describe a geographical or cultural region. It is one of several classes that provide you with the ability to write programs that can execute in several different international envirorunents. For example, the formats used to display dates, times, and numbers are different in various regions. Internationalization is a…

Read More →

Time Zone

Time Zone Another time-related class is Time Zone. The Timezone class allows you to work with time zone offsets from Greenwich mean time (GMT), also referred to as Coordinated Universal Time (UTC). It also computes daylight saving time. Time Zone only supplies the default constructor. Simple Time Zone The Simple Time Zone class is a convenient subclass of…

Read More →

Gregorian Calendar

Gregorian Calendar Gregorian Calendar is a concrete implementation of a Calendar that implements the normal Gregorian calendar with which you are familiar. The getInstance( ) method of ‘Calendar returns a Gregorian Calendar initialized with the current date and time the default locale and time zone. GregorianCalendar defines two fields D and BC..These represent the two eras defined by the…

Read More →

Date Comparison

Date Comparison There are three ways to compare two Date objects. First; you can use getTime( ) to obtain the number of milliseconds that have elapsed since midnight, January 1, 1970, for both objects and then compare these two values. Second, you can use the methods bcfore( ), after( ), and equals( ). Because the 12th of the…

Read More →

Date

Date The Date class encapsulates the current date and time. Before beginning our examination of Date, it is important to point out that it has changed substantially from its original version defined by [ava 1.0. When Java 1.1 was released, many of the functions carried out by the original Dale class were moved into the Calendar and Date Format…

Read More →

The Complete Reference

The Complete Reference ThiS chapter continues our discussion of java.util by examining those classes and interfaces that are not part of the collections framework. These include classes that tokenize strings, work with dates, compute random numbers, and observe . events. Also, the java.util.ztp and java.util.jar packages are briefly mentioned at the end of this chapter. Stringtokenizer The processing of text…

Read More →

An Observer Example

An Observer Example Here is an ‘example that demonstrates an observable object. It creates an observer class, called Watcher, that implements the Observer interface. The class being monitored is called Being Watched, It extends Observable. Inside fleeing Watched is the method counter(), which simply counts down from a specified value. It uses sleep( )to wait a tenth of…

Read More →

Back to Top