Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package bean; import java.io.UnsupportedEncodingException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; import org.ocpsoft.prettytime.PrettyTime; import java.util.Date; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.codec.binary.Base64; /** * * @author Mesong */ public class Message { private int messageID; private int toyID; private int custID; private String custName; private String content; private String date; private int rating; private int managerID = -1; private int transactionID; private int replyMsgID; private String icon; public String getCustName() { return custName; } public void setCustName(String custName) { this.custName = custName; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public int getRating() { return rating; } public void setRating(int rating) { this.rating = rating; } /** * @return the messageID */ public int getMessageID() { return messageID; } /** * @param messageID the messageID to set */ public void setMessageID(int messageID) { this.messageID = messageID; } /** * @return the toyID */ public int getToyID() { return toyID; } /** * @param toyID the toyID to set */ public void setToyID(int toyID) { this.toyID = toyID; } /** * @return the custID */ public int getCustID() { return custID; } /** * @param custID the custID to set */ public void setCustID(int custID) { this.custID = custID; } /** * @return the content */ public String getContent() { return content; } /** * @param content the content to set */ public void setContent(String content) { this.content = content; } public String getRelativeTime() { String temp = date; PrettyTime p = new PrettyTime(new Locale("en")); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date; date = sdf.parse(temp); temp = p.format(date); //System.out.println(date); //System.out.println(p.format(date)); } catch (ParseException ex) { Logger.getLogger(Message.class.getName()).log(Level.SEVERE, null, ex); return temp; } return temp; } /** * @return the managerID */ public int getManagerID() { return managerID; } /** * @param managerID the managerID to set */ public void setManagerID(int managerID) { this.managerID = managerID; } /** * @return the transactionID */ public int getTransactionID() { return transactionID; } /** * @param transactionID the transactionID to set */ public void setTransactionID(int transactionID) { this.transactionID = transactionID; } /** * @return the replyMsgID */ public int getReplyMsgID() { return replyMsgID; } /** * @param replyMsgID the replyMsgID to set */ public void setReplyMsgID(int replyMsgID) { this.replyMsgID = replyMsgID; } /** * @return the icon */ public String getIcon() { String temp = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsSAAALEgHS3X78AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuR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XumoMRUYG3R113jdHKUkzfyppIJYB5pSRmPTlKSNWZLdUAwVLujUOqrrDZLAXE4duloyBgB4sI5BX8CmARQCwAsQDEAhALvwKAWABiAYgFAMQCEAtALAAgFoBYAGIBALEAxAIQCwCIBSAWgFgAQCwAsQDEAgBiAYgFIBYAEAtALACxAIBYQDD+GwD7Va+mWivzEwAAAABJRU5ErkJggg=="; if (icon != null && !icon.equals("")) { byte[] encodeBase64 = Base64.encodeBase64(Base64.decodeBase64(icon)); String base64DataString = ""; try { temp = new String(encodeBase64, "UTF-8"); } catch (UnsupportedEncodingException ex) { Logger.getLogger(Toy.class.getName()).log(Level.SEVERE, null, ex); } return temp; } return temp; } /** * @param icon the icon to set */ public void setIcon(String icon) { this.icon = icon; } }