Skip to content

Commit

Permalink
format date
Browse files Browse the repository at this point in the history
  • Loading branch information
majko96 committed Mar 28, 2021
1 parent d531339 commit 6b0d66e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
Binary file modified .gradle/6.5/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
54 changes: 27 additions & 27 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions app/src/main/java/com/precin/covid_19_sk/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.res.Configuration;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
Expand All @@ -20,6 +21,7 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand All @@ -39,14 +41,20 @@
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;


public class MainActivity extends Activity {
Expand Down Expand Up @@ -214,6 +222,7 @@ protected String doInBackground(String... params) {
return null;
}

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
Expand All @@ -231,8 +240,12 @@ protected void onPostExecute(String result) {
Configuration sysConfig = getResources().getConfiguration();
Locale curLocale = sysConfig.locale;
NumberFormat nf = NumberFormat.getInstance(curLocale);
String dat = ("Dáta zo dňa: \n" + jObj.getString("lastUpdatedAtSource"));
dateUpdate.setText("Dáta zo dňa: \n" + jObj.getString("lastUpdatedAtSource"));
String d = jObj.getString("lastUpdatedAtSource");
Date date = Date.from( Instant.parse( d ));
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy", Locale.UK);
String formattedDate = sdf.format(date);

dateUpdate.setText("Dáta zo dňa: \n" + formattedDate);

txtDeceased.setText(Html.fromHtml(nf.format(new Integer(jObj.getString("deceased")))+"<sup><small>\t&nbsp;+"+nf.format(new Integer(jObj.getString("newDeceased")))+"</small></sup>"));

Expand Down

0 comments on commit 6b0d66e

Please sign in to comment.