Many a times the design requires adding a time stamp to output of the program. For an instance, while creating the test reports pro-grammatically, it is always advisable to add a time stamp to the test report for keeping a record. This can be achieved by using the method as below:
1 2 3 4 5 |
String getTimeStamp() { DateFormat format = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String timeStamp = format.format(new Date()); return timeStamp; } |
Various options can be tried with SimpleDateFormat constructor. Thus using the code snippet above, you can append file name with time stamp.
Please feel free to let us know better way of doing the things. Thank you.
In any case I will be subscribing for your rss feed and I am hoping you write again very soon!