Advertisement
Baru_Berbagi

Memo.java

Dec 5th, 2020
3,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. package com.baruberbagi.catatan;
  2.  
  3. import androidx.annotation.NonNull;
  4.  
  5. import java.io.Serializable;
  6. import java.text.DateFormat;
  7. import java.text.SimpleDateFormat;
  8. import java.util.Date;
  9.  
  10. public class Memo implements Serializable {
  11.     private Date date;
  12.     private String text;
  13.     private boolean fullDisplayed;
  14.     private static DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyy 'at' hh:mm aaa");
  15.  
  16.     public Memo(){
  17.         this.date = new Date();
  18.     }
  19.     public Memo(long time, String text){
  20.         this.date = new Date(time);
  21.         this.text = text;
  22.     }
  23.     public String getDate(){
  24.         return dateFormat.format(date);
  25.     }
  26.     public long getTime(){
  27.         return date.getTime();
  28.     }
  29.     public void setTime(long time){
  30.         this.date = new Date(time);
  31.     }
  32.     public void setText(String text){
  33.         this.text = text;
  34.     }
  35.     public String getText(){
  36.         return this.text;
  37.     }
  38.     public String getShortText(){
  39.         String temp = text.replaceAll("/n", " ");
  40.         if (temp.length() > 25){
  41.             return temp.substring(0, 25) + "...";
  42.         }else{
  43.             return temp;
  44.         }
  45.     }
  46.     public void setFullDisplayed(boolean fullDisplayed){
  47.         this.fullDisplayed = fullDisplayed;
  48.     }
  49.  
  50.     public boolean isFullDisplayed() {
  51.         return this.fullDisplayed;
  52.     }
  53.  
  54.     @NonNull
  55.     @Override
  56.     public String toString() {
  57.         return this.text;
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement