Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This is the Task Class
- * @author Jonathan Harris
- * May 28, 2015
- */
- import java.util.Date;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.text.ParseException;
- public class Task {
- public Date date;
- public String description;
- /**
- * Creates a new task with the given dueDate and description.
- * dueDate must be in the format mm-dd-yyyy (e.g., 07-01-2014 for 1 July 2014); it's
- * okay if this method crashes if the date format is incorrect.
- */
- public Task(String dueDate, String description) {
- DateFormat format = new SimpleDateFormat("MM-dd-yyyy");
- try {
- date = format.parse(dueDate);
- } catch (ParseException e) {
- System.err.println("Invalid Date");
- }
- this.description = description;
- }
- /**
- * Gets the description of this task.
- */
- public String getDescription() {
- return description;
- }
- /**
- * Gets the due date for this task.
- */
- public Date getDueDate() {
- return date;
- }
- public static void main(String[] args) {
- Task testTask = new Task("05-23-15", "Making test task");
- System.out.println("The task " + testTask.getDescription() + " was made on " +
- testTask.getDueDate());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement