I have an input csv file like:
0,Mike,2015-12-04 21:56:32
1,Raj,2015-12-04 11:53:29
I want to extract the timestamp from the file. What is the easiest way to do it in Java.
You can do it as follows:
while(reader.hasNext()) {
String csvString = reader.nextLine();
String[] splits = csvString.split(",");
System.out.println("Record: " + splits[0] + " Timestamp: " + splits[2]);
}
Output:
Record: 0 Timestamp: 2015-12-04 21:56:32
Record: 1 Timestamp: 2015-12-04 11:53:29
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.