有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java使用LocalTime类比较没有日期的时间

我需要一个CSV文件的交货时间(无序),我需要按时间排序,以使用数据

我正在我的roadDataToBeSorted数据结构的LinkedList中存储必要的信息,该数据结构由3个字符串组成:rName、rdZipCode和rdDeliveryTime。到目前为止,我的研究表明使用LocalTime类,因为我在rdDeliveryTime中的时间格式是HH:MM:SS

我不确定如何将字符串转换为LocalTime对象,然后使用。函数对我的数据进行排序

for (int i = 0; i < stopOrderByDeliveryTime.size() - 1; i++) {
   if (LocalTime(stopOrderByDeliveryTime.get(i).rdDeliveryTime).isBefore(LocalTime(stopOrderByDeliveryTime.get(i+1).rdDeliveryTime))) {
      // add element at index (it is earlier than later elements)
   } else {
      // add element to end since it is later than all prior elements
   }
}

共 (0) 个答案