Skip to content

Commit

Permalink
History date format
Browse files Browse the repository at this point in the history
  • Loading branch information
shiv07tiwari committed Jul 29, 2018
1 parent 5ef51af commit 97fb29c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -43,11 +44,17 @@ public void onBindViewHolder(@NonNull ViewHistoryHolder holder, int position) {
final String filePath = mHistoryList.get(position).getFilePath();
File file = new File(filePath);
final String operationDate = mHistoryList.get(position).getDate();
Log.e("log","hh : "+operationDate);
String[] formatdate = operationDate.toString().split(" ");
String time = formatdate[3];

String[] formattime = time.split(":");
String date = formattime[0] + ":" + formattime[1];
final String operationType = mHistoryList.get(position).getOperationType();
final String fileName = file.getName();

holder.mFilename.setText(fileName);
holder.mOperationDate.setText(operationDate);
holder.mOperationDate.setText(formatdate[0] + ", " + formatdate[1] + " " + formatdate[2] + " at " + date);
holder.mOperationType.setText(operationType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -20,8 +21,7 @@ public DatabaseHelper(Context mContext) {
* @param operationType operation performed on file
*/
public void insertRecord(String filePath, String operationType) {
String date = new SimpleDateFormat("dd-MM-yyyy").format(new Date());
new Insert().execute(new History(filePath, date, operationType));
new Insert().execute(new History(filePath, new Date().toString(), operationType));

}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/layout_item_history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical"
android:weightSum="2">
android:orientation="vertical">

<TextView
android:id="@+id/operationDate"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:textSize="10sp"
android:layout_weight="1"
android:padding="8dp" />

Expand Down

0 comments on commit 97fb29c

Please sign in to comment.