solve history
This commit is contained in:
parent
1c1d580a38
commit
0e86870b8b
@ -1,4 +1,5 @@
|
|||||||
package com.example.bdkipoc.histori;
|
package com.example.bdkipoc.histori;
|
||||||
|
import com.example.bdkipoc.BuildConfig;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -31,6 +32,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import com.example.bdkipoc.R;
|
import com.example.bdkipoc.R;
|
||||||
|
|
||||||
@ -65,25 +67,14 @@ public class HistoryActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildApiUrl() {
|
private void buildApiUrl() {
|
||||||
// Option 1: Get today's date (current implementation)
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||||
String todayDate = dateFormat.format(new Date());
|
String todayDate = dateFormat.format(new Date());
|
||||||
|
|
||||||
// Option 2: Set specific date (uncomment and modify if needed)
|
// Gunakan BuildConfig untuk base URL
|
||||||
// String specificDate = "2025-06-27"; // Format: yyyy-MM-dd
|
API_URL = BuildConfig.BACKEND_BASE_URL + "/transactions?page=0&limit=10&sortOrder=DESC&from_date="
|
||||||
// String todayDate = specificDate;
|
|
||||||
|
|
||||||
// Option 3: Set date using Calendar for specific date
|
|
||||||
// Calendar calendar = Calendar.getInstance();
|
|
||||||
// calendar.set(2025, Calendar.JUNE, 27); // Year, Month (0-based), Day
|
|
||||||
// String todayDate = dateFormat.format(calendar.getTime());
|
|
||||||
|
|
||||||
// Build API URL with date as both from_date and to_date, and limit=10
|
|
||||||
API_URL = "https://be-edc.msvc.app/transactions?page=0&limit=10&sortOrder=DESC&from_date="
|
|
||||||
+ todayDate + "&to_date=" + todayDate + "&location_id=0&merchant_id=0&tid=&mid=&sortColumn=id";
|
+ todayDate + "&to_date=" + todayDate + "&location_id=0&merchant_id=0&tid=&mid=&sortColumn=id";
|
||||||
|
|
||||||
// Build Summary API URL for getting total amount and transaction count
|
SUMMARY_API_URL = BuildConfig.BACKEND_BASE_URL + "/transactions/list?from_date="
|
||||||
SUMMARY_API_URL = "https://be-edc.msvc.app/transactions/list?from_date="
|
|
||||||
+ todayDate + "&to_date=" + todayDate + "&location_id=0&merchant_id=0";
|
+ todayDate + "&to_date=" + todayDate + "&location_id=0&merchant_id=0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,22 +294,29 @@ public class HistoryActivity extends AppCompatActivity {
|
|||||||
private String formatTime(String isoDate) {
|
private String formatTime(String isoDate) {
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
inputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
|
||||||
|
SimpleDateFormat outputFormat = new SimpleDateFormat("HH.mm.ss", Locale.getDefault());
|
||||||
|
outputFormat.setTimeZone(TimeZone.getDefault());
|
||||||
|
|
||||||
Date date = inputFormat.parse(isoDate);
|
Date date = inputFormat.parse(isoDate);
|
||||||
return outputFormat.format(date);
|
return outputFormat.format(date);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
return "00:00";
|
return "00.00.00";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatDate(String isoDate) {
|
private String formatDate(String isoDate) {
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||||
|
inputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
|
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
|
||||||
|
outputFormat.setTimeZone(TimeZone.getDefault());
|
||||||
|
|
||||||
Date date = inputFormat.parse(isoDate);
|
Date date = inputFormat.parse(isoDate);
|
||||||
return outputFormat.format(date);
|
return outputFormat.format(date);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
// Return today's date as fallback
|
|
||||||
SimpleDateFormat fallbackFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
|
SimpleDateFormat fallbackFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
|
||||||
return fallbackFormat.format(new Date());
|
return fallbackFormat.format(new Date());
|
||||||
}
|
}
|
||||||
@ -505,8 +503,8 @@ class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.HistoryViewHold
|
|||||||
HistoryItem item = historyList.get(position);
|
HistoryItem item = historyList.get(position);
|
||||||
|
|
||||||
// Format time with dots instead of colons (09.00 instead of 09:00)
|
// Format time with dots instead of colons (09.00 instead of 09:00)
|
||||||
String formattedTime = item.getTime().replace(":", ".");
|
String formattedTime = item.getTime().replace(":", ".") + ", " + item.getDate();
|
||||||
holder.tvTime.setText(formattedTime + ", " + item.getDate());
|
holder.tvTime.setText(formattedTime);
|
||||||
|
|
||||||
holder.tvAmount.setText("Rp. " + formatCurrency(item.getAmount()));
|
holder.tvAmount.setText("Rp. " + formatCurrency(item.getAmount()));
|
||||||
holder.tvChannel.setText(item.getChannelName());
|
holder.tvChannel.setText(item.getChannelName());
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package com.example.bdkipoc.histori;
|
package com.example.bdkipoc.histori;
|
||||||
|
import com.example.bdkipoc.BuildConfig;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -32,6 +33,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class HistoryListActivity extends AppCompatActivity {
|
public class HistoryListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -64,16 +66,11 @@ public class HistoryListActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildApiUrl() {
|
private void buildApiUrl() {
|
||||||
// Get current date in yyyy-MM-dd format
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||||
String currentDate = dateFormat.format(new Date());
|
String currentDate = dateFormat.format(new Date());
|
||||||
|
|
||||||
// Option 2: Set specific date (uncomment and modify if needed)
|
// Gunakan BuildConfig untuk base URL
|
||||||
// String specificDate = "2025-06-27"; // Format: yyyy-MM-dd
|
API_URL = BuildConfig.BACKEND_BASE_URL + "/transactions/list?from_date=" + currentDate +
|
||||||
// String currentDate = specificDate;
|
|
||||||
|
|
||||||
// Build API URL with current date as both from_date and to_date
|
|
||||||
API_URL = "https://be-edc.msvc.app/transactions/list?from_date=" + currentDate +
|
|
||||||
"&to_date=" + currentDate + "&location_id=0&merchant_id=0";
|
"&to_date=" + currentDate + "&location_id=0&merchant_id=0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,9 +241,13 @@ public class HistoryListActivity extends AppCompatActivity {
|
|||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
Transaction transaction = transactions.get(position);
|
Transaction transaction = transactions.get(position);
|
||||||
|
|
||||||
// Format date
|
// Format date with timezone conversion
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("HH:mm, dd MMM yyyy", Locale.getDefault());
|
inputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
|
||||||
|
SimpleDateFormat outputFormat = new SimpleDateFormat("HH:mm.ss, dd MMM yyyy", Locale.getDefault());
|
||||||
|
outputFormat.setTimeZone(TimeZone.getDefault());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Date date = inputFormat.parse(transaction.getDateTime());
|
Date date = inputFormat.parse(transaction.getDateTime());
|
||||||
holder.tvTime.setText(outputFormat.format(date));
|
holder.tvTime.setText(outputFormat.format(date));
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<!-- Tanggal -->
|
<!-- Tanggal (ditambahkan detik) -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_time"
|
android:id="@+id/tv_time"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:text="H:mm, dd MMM yyyy"
|
android:text="HH.mm.ss, dd MMM yyyy"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
android:fontFamily="@font/inter"
|
android:fontFamily="@font/inter"
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<!-- Waktu -->
|
<!-- Waktu (ditambahkan detik) -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_time"
|
android:id="@+id/tv_time"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:text="09.00, 07-05-2025"
|
android:text="09.00.00, 07-05-2025"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
android:fontFamily="@font/inter"
|
android:fontFamily="@font/inter"
|
||||||
android:textSize="13sp" />
|
android:textSize="13sp" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user