Changeset 17720 in josm


Ignore:
Timestamp:
2021-04-09T00:55:40+02:00 (4 years ago)
Author:
simon04
Message:

see #14176 - Migrate ChangesetDiscussionComment to Instant

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/ChangesetDiscussionComment.java

    r11878 r17720  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import java.util.Date;
    5 
    6 import org.openstreetmap.josm.tools.date.DateUtils;
     4import java.time.Instant;
    75
    86/**
     
    1311
    1412    /** date this comment was posted at */
    15     private final Date date;
     13    private final Instant date;
    1614    /** the user who posted the comment */
    1715    private final User user;
     
    2422     * @param user the user who posted the comment
    2523     */
    26     public ChangesetDiscussionComment(Date date, User user) {
    27         this.date = DateUtils.cloneDate(date);
     24    public ChangesetDiscussionComment(Instant date, User user) {
     25        this.date = date;
    2826        this.user = user;
    2927    }
     
    4947     * @return date this comment was posted at
    5048     */
    51     public final Date getDate() {
    52         return DateUtils.cloneDate(date);
     49    public final Instant getDate() {
     50        return date;
    5351    }
    5452
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java

    r17717 r17720  
    99import java.nio.charset.StandardCharsets;
    1010import java.text.MessageFormat;
    11 import java.util.Date;
     11import java.time.Instant;
    1212import java.util.LinkedList;
    1313import java.util.List;
     
    172172            // -- date
    173173            String value = atts.getValue("date");
    174             Date date = null;
    175             if (value != null) {
    176                 date = DateUtils.fromString(value);
    177             }
    178 
     174            Instant date = value != null ? DateUtils.parseInstant(value) : null;
    179175            comment = new ChangesetDiscussionComment(date, createUser(atts));
    180176        }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDiscussionCommentTest.java

    r17275 r17720  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import java.util.Date;
     6import java.time.Instant;
    77
    88import org.junit.jupiter.api.extension.RegisterExtension;
     
    2929    @Test
    3030    void testChangesetDiscussionComment() {
    31         Date d = new Date(1000);
     31        Instant d = Instant.ofEpochMilli(1000);
    3232        User foo = User.createOsmUser(1, "foo");
    3333        ChangesetDiscussionComment cdc = new ChangesetDiscussionComment(d, foo);
    3434        assertEquals(d, cdc.getDate());
    3535        assertEquals(foo, cdc.getUser());
    36         assertEquals("ChangesetDiscussionComment [date=Thu Jan 01 00:00:01 UTC 1970, user=id:1 name:foo, text='null']", cdc.toString());
     36        assertEquals("ChangesetDiscussionComment [date=1970-01-01T00:00:01Z, user=id:1 name:foo, text='null']", cdc.toString());
    3737    }
    3838
     
    4242    @Test
    4343    void testText() {
    44         ChangesetDiscussionComment cdc = new ChangesetDiscussionComment(new Date(), null);
     44        ChangesetDiscussionComment cdc = new ChangesetDiscussionComment(Instant.now(), null);
    4545        cdc.setText("foo");
    4646        assertEquals("foo", cdc.getText());
Note: See TracChangeset for help on using the changeset viewer.