Dates and Strings
Objectives
Applied
- Use the GregorianCalendar, Calendar, Date, and DateFormat classes to get the current date, to set dates, to calculate elapsed days, and to format dates.
- Use the methods of the String class to manipulate and compare strings.
- Use the StringBuilder class to create a mutable string, and use the methods of a StringBuilder object to work with the string.
- Given Java code that uses any of the language elements presented in this chapter, explain what each statement does.
Knowledge
- Describe the difference between how dates are stored in GregorianCalendar and Date objects.
- Describe two situations where you would typically use Date objects rather than GregorianCalendar objects.
- Explain the difference between a mutable and an immutable string and why it's usually more efficient to use a mutable string.
- Explain how Java determines the initial capacity of a StringBuilder object and the new capacity of a StringBuilder object when its current capacity is exceeded.