mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-25 04:22:30 +01:00
Merge pull request #102 from chschtsch/refactor
fix bug with upload date + better way to parse it
This commit is contained in:
commit
812dd9282d
@ -32,8 +32,9 @@ import android.view.MenuItem;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
@ -240,15 +241,14 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
thumbsUpView.setText(nf.format(info.like_count));
|
thumbsUpView.setText(nf.format(info.like_count));
|
||||||
thumbsDownView.setText(nf.format(info.dislike_count));
|
thumbsDownView.setText(nf.format(info.dislike_count));
|
||||||
|
|
||||||
//this is horribly convoluted
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
//TODO: find a better way to convert YYYY-MM-DD to a locale-specific date
|
Date datum = null;
|
||||||
//suggestions are welcome
|
try {
|
||||||
int year = Integer.parseInt(info.upload_date.substring(0, 4));
|
datum = formatter.parse(info.upload_date);
|
||||||
int month = Integer.parseInt(info.upload_date.substring(5, 7));
|
} catch (ParseException e) {
|
||||||
int date = Integer.parseInt(info.upload_date.substring(8, 10));
|
e.printStackTrace();
|
||||||
Calendar cal = Calendar.getInstance();
|
}
|
||||||
cal.set(year, month, date);
|
|
||||||
Date datum = cal.getTime();
|
|
||||||
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
|
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
|
||||||
|
|
||||||
String localisedDate = df.format(datum);
|
String localisedDate = df.format(datum);
|
||||||
|
Loading…
Reference in New Issue
Block a user