Select to view content in your preferred language

Set Date for Feature

660
1
06-19-2019 11:48 AM
by Anonymous User
Not applicable

How do we set the date value for feature attribute, when creating new feature. Here is what I am trying by setting as String

String dateTime = imgData.getAttribute(ExifInterface.TAG_DATETIME);
Date photoDate;
if(dateTime != null) {
 String photoDatePat = "yyyy:MM:dd HH:mm:ss";
 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(photoDatePat, Locale.US);
 photoDate = simpleDateFormat.parse(dateTime);
}else {
 photoDate = new Date();
}
attributes.put(Fields.PHOTO_DATE, photoDate.toString());

, and when setting as a date type 

attributes.put(Field.PHOTO_DATE, photoDate)

this errors out as 'Conversion to CoreElement not implemented: class java.util.Date'

0 Kudos
1 Reply
GuntherHeppner
Esri Contributor

Hi Vikrant,

It depends of the FieldType of your feature's date attribute. If it's of type DATE, you should set a value of type Calendar. If it's of type TEXT, then you should set a value of type String, as you have tried above. See also:
https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/data/Fie...

Gunther

0 Kudos