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