Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 合并自定义类中的项_Java_List_Java Stream - Fatal编程技术网

Java 合并自定义类中的项

Java 合并自定义类中的项,java,list,java-stream,Java,List,Java Stream,我有以下几点 List<String> namesList = aList.stream() .map(rollingD::getSettDate) .collect(Collectors.toList()); List namesList=aList.stream() .map(rollingD::getSettDate) .collect(

我有以下几点

List<String> namesList = aList.stream()
                                   .map(rollingD::getSettDate)
                                   .collect(Collectors.toList());
List namesList=aList.stream()
.map(rollingD::getSettDate)
.collect(Collectors.toList());

List namesList1=aList.stream()
.map(rollingD::GetPublishingPeriod开始时间)
.collect(Collectors.toList());
PublishingPeriodCommittengTime和SettDate都存在于同一列表中

如何组合我的两个项目,以便获得getSettDate+“”+GetPublishingPeriod开始时间

getSettDate类似于示例01/01/2020,GetPublishingPeriodCommitingTime类似于示例01:10:33

我想获得一个日期时间戳,如dd/mm/yyyy hh:mm:ss

List stamps=IntStream.range(0,nameList.size())
List<Strings> stamps = IntStream.range(0, nameList.size())
    .map(i->nameList.get(i) + " " + nameList1.get(i))
    .collect(Collectors.toList())
.map(i->nameList.get(i)+“”+nameList1.get(i)) .collect(收集器.toList())
但是为什么不使用原始列表呢

List<String> stamps = aList.stream()
     .map(x->x.getSettDate() + " " + x.getPublishingPeriodCommencingTime())
     .collect(Collectors.toList());
List stamps=aList.stream()
.map(x->x.getSettDate()+“”+x.GetPublishingPeriodCommentTime())
.collect(Collectors.toList());
List namesList=aList.stream()
.map(rollingD->rollingD.getSettDate()+“”+
rollingD.GetPublishingPeriodCommentingTime())
.collect(Collectors.toList());

对于日期和时间格式,您可以使用SimpleDateTimeFoMatter,这正是我想要的。谢谢!:)
List<String> stamps = aList.stream()
     .map(x->x.getSettDate() + " " + x.getPublishingPeriodCommencingTime())
     .collect(Collectors.toList());
     List<String> namesList = aList.stream()
                               .map(rollingD -> rollingD.getSettDate() + " " + 
                                    rollingD.getPublishingPeriodCommencingTime())
                               .collect(Collectors.toList());