JavaFX/model/NewsModel.java

92 lines
1.8 KiB
Java
Raw Normal View History

package model;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
2017-11-19 13:44:40 +00:00
import java.util.ArrayList;
import java.util.Date;
2017-11-19 13:44:40 +00:00
import Classes.Category;
public class NewsModel {
private String author;
private String source;
private String imageURL;
private String newsURL;
private String title;
private String description;
2017-11-19 13:44:40 +00:00
private ArrayList<Category> tags;
private Date date;
2017-11-19 13:44:40 +00:00
public NewsModel(){
this.tags = new ArrayList<Category>();
}
public NewsModel addTag(Category tag) {
this.tags.add(tag);
return this;
}
public String getAuthor() {
return author;
}
public NewsModel setAuthor(String author) {
this.author = author;
return this;
}
public String getSource() {
return source;
}
public NewsModel setSource(String source) {
this.source = source;
return this;
}
public String getImageURL() {
return imageURL;
}
public NewsModel setImageURL(String imageURL) {
this.imageURL = imageURL;
return this;
}
public String getNewsURL() {
return newsURL;
}
2017-11-19 13:44:40 +00:00
public ArrayList<Category> getTags() {
return tags;
}
public NewsModel setNewsURL(String newsURL) {
this.newsURL = newsURL;
return this;
}
public String getTitle() {
return title;
}
public NewsModel setTitle(String title) {
this.title = title;
return this;
}
public String getDescription() {
return description;
}
public NewsModel setDescription(String description) {
this.description = description;
return this;
}
public Date getDate() {
return date;
}
public NewsModel setDate(String date) throws ParseException {
//on déclare le format de date
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
date = date.replace("Z", "+0000");
this.date = fmt.parse(date);
return this;
}
public NewsModel setDate(Date date){
this.date = date;
return this;
}
}