Skip to content

Date doesn't work (wrong format in unit test) - additional notes #8

@tfonfara

Description

@tfonfara

I found some timezone problems, the date object in the plist file and the java.util.Date object are different, so if you create a new date formatter and set the timezone (e.g. "GMT+2") the new date object has the wrong time (in this example 8AM instead of 10AM, because of GMT+2) To fix this just set the timezone of the date formatter in your com.longevitysoft.android.xml.plist.domain.Date constructor to UTC (because all dates in plists are in UTC) and everything works fine.

public Date() {
    setType(PListObjectType.DATE);
    iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    iso8601Format.setTimeZone(TimeZone.getTimeZone("UTC"));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions