mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 10:58:23 +01:00
parent
20c317b63f
commit
b1b12aba31
@ -9,13 +9,15 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.time.ZoneId;
|
import java.text.ParseException;
|
||||||
import java.time.ZonedDateTime;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -278,9 +280,19 @@ public class ParseComment {
|
|||||||
String authorQualifiedName = LemmyUtils.actorID2FullName(creatorObj.getString("actor_id"));
|
String authorQualifiedName = LemmyUtils.actorID2FullName(creatorObj.getString("actor_id"));
|
||||||
String linkAuthor = creatorObj.getString("actor_id");
|
String linkAuthor = creatorObj.getString("actor_id");
|
||||||
long commentTimeMillis = 0;
|
long commentTimeMillis = 0;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
||||||
commentTimeMillis = ZonedDateTime.parse(commentObj.getString("published"),
|
String dateStr = commentObj.getString("published");
|
||||||
DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.of("Z"))).toInstant().toEpochMilli();
|
|
||||||
|
dateStr = dateStr.substring(0, dateStr.lastIndexOf(".") + 4) + 'Z';
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
try {
|
||||||
|
Date date = sdf.parse(dateStr);
|
||||||
|
if (date != null) {
|
||||||
|
commentTimeMillis = date.getTime();
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String commentMarkdown = commentObj.getString("content");
|
String commentMarkdown = commentObj.getString("content");
|
||||||
String commentRawText = commentObj.getString("content");
|
String commentRawText = commentObj.getString("content");
|
||||||
|
@ -18,13 +18,15 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.ZoneId;
|
import java.text.ParseException;
|
||||||
import java.time.ZonedDateTime;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -151,10 +153,21 @@ public class ParsePost {
|
|||||||
String author = creator.getString("name");
|
String author = creator.getString("name");
|
||||||
String authorFull = LemmyUtils.actorID2FullName(creator.getString("actor_id"));
|
String authorFull = LemmyUtils.actorID2FullName(creator.getString("actor_id"));
|
||||||
long postTimeMillis = 0;
|
long postTimeMillis = 0;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
||||||
postTimeMillis = ZonedDateTime.parse(post.getString("published"),
|
String dateStr = post.getString("published");
|
||||||
DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.of("Z"))).toInstant().toEpochMilli();
|
|
||||||
|
dateStr = dateStr.substring(0, dateStr.lastIndexOf(".") + 4) + 'Z';
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
try {
|
||||||
|
Date date = sdf.parse(dateStr);
|
||||||
|
if (date != null) {
|
||||||
|
postTimeMillis = date.getTime();
|
||||||
}
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
String title = post.getString("name");
|
String title = post.getString("name");
|
||||||
String permalink = post.getString("ap_id");
|
String permalink = post.getString("ap_id");
|
||||||
int score = counts.getInt("score");
|
int score = counts.getInt("score");
|
||||||
|
Loading…
Reference in New Issue
Block a user