What you do with that data when you have it is up to you.
The Date class supplies two methods that provide you with a way of extracting the day from a Date
object: getDay and getDate . You ??™ ll find that these two methods aren ??™ t terribly descriptive, as they both
return the day component of your Date object. However, while the method getDate returns the day of
the month as an integer between 1 and 31, getDay returns the day of the week as an integer between 0
and 6, where 0 is Sunday, 1 is Monday, 2 is Tuesday and so on:
var dayOfMonth : Int = birthDate.getDate(); // 1 ... 31
var dayOfWeek : Int = birthDate.getDay(); // 0 = Sunday, 1 = Monday ...
If you apply both methods to the birthday, you will receive 3 from the call to getDate and 3 from the call
to getDay , as the date was a Wednesday.
Extracting the month and year components of a Date object is a little more foolproof. To help you with
these tasks, you are provided with the aptly named getMonth and getFullYear methods. getMonth
returns the month of the year as an integer from 0 to 11, with 0 representing January and so on, much
like the value required when instantiating the Date object.
Pages:
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139