dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Beginner
May 5, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Setting Dates With Calendar and GregorianCalendar

In Java 1.0.2, the java.util.Date class was used to represent a point in time, as well as to parse and format date values. However, as part of the internationalization features introduced with Java 1.1, most of the methods in Date were deprecated, and the java.util.Calendar and java.util.GregorianCalendar classes were added. Calendar is an abstract class and cannot be instantiated, while GregorianCalendar is a concrete subclass of Calendar that's often useful when working with date and/or time values. There are a number of GregorianCalendar constructors that you can use when creating date/time representations. For example, to create an instance that corresponds to July 4, 1776, use:
 
GregorianCalendar grc =
new GregorianCalendar(1776, Calendar.JULY, 4);
You can also create an instance that includes a specific time value, such as 12:34:56 as follows:
 
GregorianCalendar grc =
new GregorianCalendar(1776, Calendar.JULY, 4, 12, 34, 56);
The Calendar and GregorianCalendar classes provide many useful methods for such functions as date arithmetic, identifying leap years, and so forth.
Brett Spell
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date