3breadt / dd-plist

A java library providing support for ASCII, XML and binary property lists.
Other
258 stars 94 forks source link

How to make PList 'date' format key start with uppercase #87

Closed extraSix closed 9 months ago

extraSix commented 1 year ago

The Apple mdm documentation shows that profile keys need to start with uppercase, such as RemovalDate (in "date" format). However, plist does not support specifying the key to be converted to string. So I have to use Jackson to convert it as follows: POJO -> Map -> NSObject -> String

public class Profile {
    @JsonProperty("RemovalDate")
    private Date removalDate;
}

Not: POJO -> NSObject -> String

However, the 'RemovalDate' in the Map is in String format, not in Date format. It caueses a conversion error. I got:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>RemovalDate</key>
    <string>2023-08-07T07:53:18Z</string>
</dict>
</plist>

It shuold be <date>...</date>:

    <key>RemovalDate</key>
    <date>2023-08-07T07:53:18Z</date>

Is there any solution? Thanks.

3breadt commented 1 year ago

In the object you pass to NSObject.fromJavaObject is the RemovalDate a string or a date (java.util.Date)? It must be a date so that it is serialized as <date>...</date>.