getDayOfYear() with leading 0's

getDayOfYear() with leading 0's

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:
  1. if (((input.Wash_Date  !=  null)  &&  (input.Washpack_Step  !=  null))  &&  (input.Batch  !=  null))
  2. {
  3.     year = ((input.Wash_Date.getYear()).toString().getSuffix("20")).toLong();
  4.     step = Washpack_Step[ID == input.Washpack_Step].Number;
  5.     batchno = input.Batch;
  6.     lotcode = (((((year + "" + (input.Wash_Date.getDayOfYear())) + "") + step) + "") + batchno).toLong();
  7.     input.Lot_Code = lotcode;
  8. }
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)