I was just wondering if there is a need of TimeSpan in java.util
so that I can define how much hours,minutes and seconds are there in between these two times.
From this TimeSpan
we can have a time interval between two times. like
TimeSpan getTimeSpan( Date before, Date after ){...}
or
long timeSpan = System.currentTimeMillis();
// ... long job
timeSpan = System.currentTimeMillis() - timeSpan;
TimeSpan ts = new TimeSpan(timeSpan);
and with this TimeSpan
we can use it in SimpleDateFormat
.
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
format.format( timsSpan );
I am not sure if this is already been implemented in Java but yet undiscovered by me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…