I am trying to use getDayOfYear() to generate a date code for orders, but would like the output of the Day of Year to always have three digits.
For example, I would like Jan 1st to be 001 instead of 1.
Feb. 3rd would be 034 instead of 34.
Here is how I am using it:
- if (((input.Wash_Date != null) && (input.Washpack_Step != null)) && (input.Batch != null))
- {
- year = ((input.Wash_Date.getYear()).toString().getSuffix("20")).toLong();
- step = Washpack_Step[ID == input.Washpack_Step].Number;
- batchno = input.Batch;
- lotcode = (((((year + "" + (input.Wash_Date.getDayOfYear())) + "") + step) + "") + batchno).toLong();
- input.Lot_Code = lotcode;
- }
Final Code is YYDDDSB
YY = 2 Digit year (i.e. 14 = 2014)
DDD =
3 digit day of year (i.e. 001 = Jan 1) [
I have been unable to achieve less than 3 digits on days under 100.
S = Step (user determined value)
B = Batch (user determined value)