In this case, it uses the name ORDERDATE to correctly
identify which value to use. This is similar to a Map in Java. This returns a Date type.
As it is returning a Date type, we have access to all properties and methods that
are accessible to a Date type. In this case, we are using the method getFullYear()
to return the 4 digit year as an Integer type. Then we use the + "-" to concatenate
a character String of "-" to the 4 digit date. This will automatically convert the 4
digit date to a String, and concatenate the dash to the end; then we assign the whole
thing to the combinedDate variable. The result of this statement (assuming the
ORDERDATE value is "2005-JAN-01") is "2005-".
Next, we use conditional logic??”in this case an IF statement??”to test if the month
value of the ORDERDATE.getMonth() is less than 10. If it is, we need to prefix the
numeric month with a 0; otherwise it will just add the 2 digit month to our String. In
the case of "2005-JAN-01", the returned value will be a 0, with the +1 correcting the
offset month value. The IF statement will return true, and use the following line:
combinedDate += "0" + (row["ORDERDATE"].getMonth() + 1);
This will ensure that we have a 0 preceding our month value. The resulting value of
combinedDate is now "2005-01".
The final statement will just return the value of combinedDate.
Pages:
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189