每日一题 为了工作 2020 0503 第六十二题
//比较日期大小
package data.bjsj.fjjb;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class test {
public static void main(String[] args) throws IOException {
String[] flags = getFailureFlag();
String time = "2015-11-03 21:37:22";
int tip = getCategory(time, flags);
System.err.println(tip);
}
public static int getCategory(String time,String[] data){
// 2015-11-01 20:22:25
// 2015-11-04 21:37:06,2015-11-04 22:29:33
for (String line:data){
String[] times = line.split(",");
if (!(0>time.compareTo(times[0])) && !(0<time.compareTo(times[1]))){
return 1;
}
}
return 0;
}
public static String[] getFailureFlag() throws IOException {
// 读取分组信息的表示
String pathName = "./fjsj/15_failureinfo.csv";
File inputFile = new File(pathName);
InputStream isr = new FileInputStream(inputFile);
BufferedReader br = new BufferedReader(new InputStreamReader(isr));
String lineData;
List<String> list = new ArrayList<>();
while ((lineData = br.readLine())!= null){
list.add(lineData);
}
String[] result = new String[list.size()];
int i = 0;
for (String elem:list){
result[i++]=elem;
}
return result;
}
}