I changed all of Dates field variables (except mYear) from int to byte to save memory.

updated comments
This commit is contained in:
2011-01-05 15:44:18 +00:00
parent a1ee23cd53
commit d103d1a070
2 changed files with 48 additions and 19 deletions

View File

@@ -12,11 +12,11 @@ package com.TwentyCodes.java.OrderProcessor;
*/
public class Date implements Comparable<Date>{
private int mHour;
private int mMinute;
private int mSecond;
private int mMonth;
private int mDay;
private byte mHour;
private byte mMinute;
private byte mSecond;
private byte mMonth;
private byte mDay;
private int mYear;
/**
@@ -32,14 +32,14 @@ public class Date implements Comparable<Date>{
String[] time = parts[1].split(":");
try {
this.mYear = Integer.parseInt(removeFirstChar(date[0]));
this.mDay = Integer.parseInt(date[2]);
this.mMonth = Integer.parseInt(date[1]);
this.mHour = Integer.parseInt(time[0]);
this.mMinute = Integer.parseInt(time[1]);
this.mSecond = Integer.parseInt(removeLastChar(time[2]));
this.mDay = Byte.parseByte(date[2]);
this.mMonth = Byte.parseByte(date[1]);
this.mHour = Byte.parseByte(time[0]);
this.mMinute = Byte.parseByte(time[1]);
this.mSecond = Byte.parseByte(removeLastChar(time[2]));
} catch (NumberFormatException e) {
e.printStackTrace();
throw new InvalidDateFormatException();
throw new InvalidDateFormatException(newDate);
}
}
@@ -99,26 +99,56 @@ public class Date implements Comparable<Date>{
}
private int getSecond() {
/**
* getter for second
* @return seconds
* @author ricky barrette
*/
private byte getSecond() {
return this.mSecond;
}
private int getMinute() {
/**
* getter for minutes
* @return minutes
* @author ricky barrette
*/
private byte getMinute() {
return this.mMinute;
}
private int getHour() {
/**
* getter for hours
* @return hours
* @author ricky barrette
*/
private byte getHour() {
return this.mHour;
}
private int getDay() {
/**
* getter for day
* @return day
* @author ricky barrette
*/
private byte getDay() {
return this.mDay;
}
private int getMonth() {
/**
* getter for month
* @return month
* @author ricky barrette
*/
private byte getMonth() {
return this.mMonth;
}
/**
* getter for year
* @return year
* @author ricky barrette
*/
private int getYear() {
return this.mYear;
}

View File

@@ -86,14 +86,13 @@ public class Order implements Comparable<Order>{
}
/**
* Compares orders by item name
* Compares orders by orders creation date
* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
* @author ricky barrette
*/
@Override
public int compareTo(Order o) {
// return this.mItemName.compareTo(o.getItemName());
return this.mOrderCreationDate.compareTo(o.getOrderCreationDate());
}