使用JAK在Java中为KML文件添加时间

时间:2017-11-19 19:54:02

标签: java timestamp kml jak

我试图为我的KML文件添加时间,但我不知道如何添加。我知道根据格式我需要在坐标之前添加它但我找不到正确的命令..帮助将非常感激=) 这是我到目前为止的代码:

String time=filteredStrings.get(i).get(4);
String timestamp=TimeConvert(time); // a function to get the right time format
String Location=filteredStrings.get(i).get(1)+","+filteredStrings.get(i).get(0);    
    doc.createAndAddPlacemark().withName("point"+i).withOpen(Boolean.TRUE).createAndSetTimeStamp().addToObjectSimpleExtension(timestamp)
            .createAndSetPoint().addToCoordinates(Location);

1 个答案:

答案 0 :(得分:0)

createAndSetTimeStamp()方法返回TimeStamp对象而不是地标,因此在创建时间戳后设置位置不起作用。

只需创建一个地标对象,然后在其上设置位置和时间。

    Placemark place =  doc.createAndAddPlacemark().withName("point1")
            .withOpen(Boolean.TRUE);
    place.createAndSetPoint().addToCoordinates(Location);
    place.createAndSetTimeStamp().withWhen("2017-11-22T00:00:00Z");
相关问题