Skip to content

Commit

Permalink
honor JOSM date/time preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
don-vip committed Jul 10, 2021
1 parent 5ea0e79 commit d785ab5
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.format.FormatStyle;
import java.util.Arrays;
import java.util.Collection;

Expand All @@ -28,6 +28,7 @@
import org.openstreetmap.josm.gui.util.GuiHelper;
import org.openstreetmap.josm.tools.ImageProvider;
import org.openstreetmap.josm.tools.Shortcut;
import org.openstreetmap.josm.tools.date.DateUtils;

/**
*
Expand Down Expand Up @@ -286,12 +287,11 @@ public void selection(Collection<? extends OsmPrimitive> selection) {

for (OsmPrimitive element : selection) {
if (!element.isNew()) {

typeObj = element.getType().toString();
try {
user = element.getUser().getName();
timestamp = new SimpleDateFormat("yyyy/MM/dd hh:mm a")
.format(element.getInstant().toEpochMilli());
timestamp = DateUtils.getDateTimeFormatter(FormatStyle.MEDIUM, FormatStyle.SHORT)
.format(element.getInstant());
} catch (NullPointerException e) {
user = UserIdentityManager.getInstance().getUserName();
}
Expand All @@ -301,7 +301,6 @@ public void selection(Collection<? extends OsmPrimitive> selection) {

DecimalFormat df = new DecimalFormat("#.00000");
coordinates = df.format(element.getBBox().getCenter().lat()) + "," + df.format(element.getBBox().getCenter().lon());

}
}

Expand Down Expand Up @@ -340,8 +339,8 @@ public void getInfoNotes(MouseEvent e) {
lbIdobj.setText(Long.toString(noteLayer.getNoteData().getSelectedNote().getId()));
}
lbVersion.setText("");
lbTimestamp.setText(new SimpleDateFormat("yyyy/MM/dd hh:mm a")
.format(noteLayer.getNoteData().getSelectedNote().getCreatedAt().toEpochMilli()));
lbTimestamp.setText(DateUtils.getDateTimeFormatter(FormatStyle.MEDIUM, FormatStyle.SHORT)
.format(noteLayer.getNoteData().getSelectedNote().getCreatedAt()));
}
}
}
Expand Down

0 comments on commit d785ab5

Please sign in to comment.