Skip to content
Snippets Groups Projects
Commit 3f8c4369 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

upgrade to java.time

parent f9dde04c
No related branches found
No related tags found
No related merge requests found
......@@ -49,13 +49,13 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* Create a track from DIS ESPDUs
......@@ -63,11 +63,11 @@ import java.util.Date;
*/
public class PduTrack
{
private String descriptor = new String();
private ArrayList<Pdu> pduList = new ArrayList<>();
private EntityStatePdu initialEspdu;
private String descriptor = new String();
private ArrayList<Pdu> pduList = new ArrayList<>();
private EntityStatePdu initialEspdu;
private EntityStatePdu latestEspdu;
private Vector3Double initialLocation;
private Vector3Double initialLocation;
private Vector3Double latestLocation;
/** waypoint timelineList in seconds */
......@@ -85,18 +85,29 @@ public class PduTrack
private String x3dOrientationInterpolatorDEF = new String();
private boolean addLineBreaksWithinKeyValues = false;
protected PduFactory pduFactory = new PduFactory();
DisTime.TimestampStyle timestampStyle = DisTime.TimestampStyle.IEEE_ABSOLUTE;
protected ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
protected DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
private String TRACE_PREFIX = "[" + (PduTrack.class.getSimpleName()) + "] ";
protected PduFactory pduFactory = new PduFactory();
public DisTime.TimestampStyle timestampStyle = DisTime.TimestampStyle.IEEE_ABSOLUTE;
private LocalDateTime recordingStart;
private LocalDateTime recordingStop;
private String todaysDateString = new String();
protected ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
protected DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
private String TRACE_PREFIX = "[" + (PduTrack.class.getSimpleName()) + "] ";
/**
* Constructor for PduTrack
*/
public PduTrack()
{
// can place initialization code here
// initialization code here
// https://docs.oracle.com/javase/tutorial/datetime/TOC.html
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/package-summary.html
// https://stackoverflow.com/questions/5175728/how-to-get-the-current-date-time-in-java/5175900 (scroll down to java.time)
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy");
todaysDateString = LocalDate.now().format(formatter);
// System.out.println(TRACE_PREFIX + "today=" + todayString);
}
/**
......@@ -107,6 +118,7 @@ public class PduTrack
{
timestampStyle = newTimestampStyle;
DisTime.setTimestampStyle(newTimestampStyle);
// automatic super invocation: return PduTrack();
}
/**
......@@ -642,7 +654,7 @@ public class PduTrack
* @return X3D PositionInterpolator as string
*/
public String createX3dModelHeaderString()
{
{
StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\n");
......@@ -653,12 +665,8 @@ public class PduTrack
sb.append(" <meta content='").append(getX3dModelName()).append("' name='title'/>").append("\n");
sb.append(" <meta content='Conversion of ESPDU track into X3D animation interpolators and LineSet.' name='description'/>").append("\n");
// https://docs.oracle.com/javase/tutorial/datetime/TOC.html
// https://stackoverflow.com/questions/5175728/how-to-get-the-current-date-time-in-java/5175900
DateFormat dateFormat = new SimpleDateFormat("d MMMM yyyy");
Date date = new Date();
sb.append(" <meta content='1 January 2022' name='created'/>").append("\n");
sb.append(" <meta content='").append(dateFormat.format(date)).append("' name='modified'/>").append("\n");
sb.append(" <meta content='").append(todaysDateString).append("' name='modified'/>").append("\n");
if (!getAuthor().isEmpty())
sb.append(" <meta content='").append(getAuthor()).append("' name='creator'/>").append("\n");
if (!getX3dModelIdentifier().isEmpty())
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment