I am trying to see how I can change the DateToStr (Unix time) when an Array item is showing. Currently it is always showing the same time.
public class Testarray {
public static void main(String args[]) {
SimpleDateFormat format = new SimpleDateFormat("yyMMddHHmmss");
String DateToStr = format.format(new Date());
String[] anArray = {
"001,"+ DateToStr +",,F,", "001,"+ DateToStr +",,F,", "001,"+ DateToStr +",,F,"
};
for (int i =0 ;i <anArray.length;i++) {
try{
// show array element every 10sc with new date and time.
Thread.sleep(10000);
}catch(InterruptedException ex){
}
System.out.println(anArray[i]);
}
}
Current output:
001,181102074606,,F,
001,181102074606,,F,
001,181102074606,,F,
Expected output: each output should have new date as it is 10 seconds delayed.