mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Fix a problem in ShareXMLParser.java, with the expitation date
This commit is contained in:
parent
b7c136286e
commit
ebe9c9fe92
@ -26,7 +26,10 @@ package com.owncloud.android.lib.resources.shares;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
@ -80,6 +83,8 @@ public class ShareXMLParser {
|
|||||||
|
|
||||||
private static final String TYPE_FOLDER = "folder";
|
private static final String TYPE_FOLDER = "folder";
|
||||||
|
|
||||||
|
private static final String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
|
||||||
|
|
||||||
private static final int SUCCESS = 100;
|
private static final int SUCCESS = 100;
|
||||||
private static final int FAILURE = 403;
|
private static final int FAILURE = 403;
|
||||||
private static final int FILE_NOT_FOUND = 404;
|
private static final int FILE_NOT_FOUND = 404;
|
||||||
@ -312,7 +317,7 @@ public class ShareXMLParser {
|
|||||||
} else if (name.equalsIgnoreCase(NODE_EXPIRATION)) {
|
} else if (name.equalsIgnoreCase(NODE_EXPIRATION)) {
|
||||||
String value = readNode(parser, NODE_EXPIRATION);
|
String value = readNode(parser, NODE_EXPIRATION);
|
||||||
if (!(value.length() == 0)) {
|
if (!(value.length() == 0)) {
|
||||||
share.setExpirationDate(Long.parseLong(readNode(parser, NODE_EXPIRATION))); // check if expiration is in long format or date format
|
share.setExpirationDate(convertToDate(value).getTime()); //Long.parseLong(readNode(parser, NODE_EXPIRATION))); // check if expiration is in long format or date format
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (name.equalsIgnoreCase(NODE_TOKEN)) {
|
} else if (name.equalsIgnoreCase(NODE_TOKEN)) {
|
||||||
@ -402,4 +407,20 @@ public class ShareXMLParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert String to Date
|
||||||
|
* @param dateString
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Date convertToDate(String dateString){
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||||
|
Date convertedDate = new Date();
|
||||||
|
try {
|
||||||
|
convertedDate = dateFormat.parse(dateString);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return convertedDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user