给定日期和时间的字符串格式,例如“ 20 10 50”,我已经通过引用互联网成功地将其转换为SDF。现在如何在刚创建的同一天操作?
X=3600*HH+60*MM+SS
public static void main(String[] args) throws ParseException {
int numberOfTests=3;
String [] timeStamps=new String[3];
timeStamps[0]="10 10 10";
timeStamps[1]="10 10 16";
timeStamps[2]="10 10 50";
int [] X=new int[3];
DateFormat sdf = new SimpleDateFormat("hh mm ss");
Date t1=sdf.parse(timeStamps[0]);
Date t2=sdf.parse(timeStamps[1]);
Date t3=sdf.parse(timeStamps[2]);
//X=3600*HH+60*MM+SS
这是我已经达到的程度。我知道这之后我该怎么办,我已经把所有事情都整理好了,但是我被困在这里。
I tried to do it using split
at first, but it became complex later on, so I stuck to this method.
If you just want to apply
X = 3600*HH + 60*MM + SS
you don't need to pass through a date (eitherDate
orLocalTime
) just use theString