Java Calendar Tutorial Essay

Published: 2021-06-11 08:45:04
essay essay

Category: History

Type of paper: Essay

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Hey! We can write a custom essay for you.

All possible types of assignments. Written by academics

This tutorial is designed to supply you with an apprehension of the Java Calendar category. it’s backgrounds. intent and uses. It is created in such a mode as to let even get downing Java coders an apprehension and feel for the utilizations of the Java Calendar category. The Java Calendar category was added to the Java Development Kit in JDK 1. 1. It is designed to allow the transition between a specific case in clip and a set of Calendar Fieldss. ( Oracle. 2004. 2010 ) What precisely does this mean? The Calendar category uses a immense array of tabular arraies to maintain path of clip based on daylight nest eggs clip. timezones. and calendar history. the calendar category uses a system clip to find where whatever event is being tracked falls on in the internal calendar tabular arraies. Some confusion is caused by this as Java does maintain path of specific location clip. and the coder needs to maintain this in head when utilizing the Calendar category even when it isn’t relevant to the job being addressed ( Roedy Green. Canadian Mind Products. 1196-2011 ) .
How to utilize the Calendar Class
The Calendar Class and it’s associated methods are used by three methods. The coder can import the calendar category and whatever specific method or builder they will utilize in their plan by importing it as importjava. util. specificfunction ;
For case. if the coder wished to put the day of the month within a plan. but that was all that was needed. for case no day of the month specific math was needed as in a log file. so the coder could utilize. importjava. util. Calendar. set ;
If the coder needs to hold greater functionality associated with the day of the months being used within a plan the coder should utilize the full Calendar category. This takes up more infinite within a plan. nevertheless provides a much simpler method of naming points from the Java Calendar category as all of it’s functionality is available to the full plan. This format would merely be. importjava. util. Calendar ;
Finally the coder can name within the plan any specific map required within the Calendar category by utilizing a to the full qualified name for the method being used. if the coder wished to utilize the set map one time within a plan and that was all that was needed the coder could merely utilize public nothingness Java. util. Calendar. set
For easiness of usage of associated Java Calendar methods and concepts nevertheless it is by and large recommended that the coder use the import map and import the full Calendar category. This provides for significantly less clip cryptography. and less possibility of errors in typing out bids and codification as less codification is necessary.
Melissa Robinsons Section
Every so frequently a plan wishes to cognize something about a day of the month. such as what twenty-four hours of the hebdomad something took topographic point or possibly you would wish to cognize which of the 12 months have 30 yearss. This can be completed with the Calendar category within the Java. util bundle. The really first thing that should be done is to import the bundle: import Java. util. Calendar ;
The following thing to make is to acquire an case of the Calendar category: Calendar cal = Calendar. getInstance ( ) ; Be aware that the builder can non straight be called upon with new Calendar ( ) ; . since it’s an abstract category. The following thing to make is set the day of the month and clip of what is wanted to cognize approximately certain things: cal. set ( twelvemonth. month. twenty-four hours ) ;
For the month parametric quantity. January is 0. February is 1. March is 2. etc. The invariables Calendar. MONTH can besides be used. Each and every calendar has a set of boundaries that are automatically updated when the calendar is altered. The get ( ) method can entree these and a set of invariables that characterize a figure of available Fieldss. So it can be noted that some really precise things can be done with the calendar now. For illustration. the hebdomad of the twelvemonth that a twenty-four hours falls on can be found by utilizing: int hebdomad = cal. acquire ( Calendar. WEEK_OF_YEAR )
Or For illustration. Use the getActualMaximum ( ) to happen the figure of yearss in a certain month: intdaysInMonth = cal. getActualMaximum ( Calendar. DAY_OF_MONTH ) ; Here are some Fieldss that may be utile within the Calendar Class: * DAY_OF_WEEK – Returns the twenty-four hours of the hebdomad that a twenty-four hours falls on. 1 through 7 yearss. * DAY_OF_YEAR – Returns the figure of yearss into the twelvemonth that the day of the month occurs * WEEK_OF_MONTH – Returns the hebdomad figure in the current month where the day of the month occurs * DAY_OF_MONTH – Returns the current twenty-four hours of the month
Andrew McCutchan’s SectionExamples of Calendar Class Use:Below are some typical illustrations of the use of the Java calendar category. /* Java CalendarFollow along with this illustration in a text editor to hold Java show todays day of the month and clip. */import Java. util. Calendar ;public category JavaCalendar {public inactive nothingness chief ( threading [ ] args ) {Calendar cal = Calendar. getInstance ( ) ;System. out. println ( “Today is: ” + cal. getTime ( ) ) ;
By following the formats for cal. acquire cases mentioned above. one can happen the assorted day of the months. times. hebdomads. and months in current formats. or in preset periods. This method allows coders to put specific clip restraints when coding for specific consequences.
End of Section
Methods Within the Calendar ClassThere are many methods within the calendar category. Methods are used for questioning. puting. and making arithmetic on the assorted Fieldss of the day of the month and clip. The most normally used methods are: * attention deficit disorder ( )
* set ( )* axial rotation ( )
Mentions1. Prophet. ( 2004. 2010 ) . Java. util Class Calendar. Retrieved from hypertext transfer protocol: //download. prophet. com/javase/1. 5. 0/docs/api/java/util/Calendar. html # set ( int. int ) 2. Roedy Green. Canadian Mind Products. ( 1196-2011 ) . Calendar: Java Glossary. Retrieved from hypertext transfer protocol: //mindprod. com/jgloss/calendar. hypertext markup language

Warning! This essay is not original. Get 100% unique essay within 45 seconds!


We can write your paper just for 11.99$

i want to copy...

This essay has been submitted by a student and contain not unique content

People also read