Aggiornato Date con soluzione prof
This commit is contained in:
parent
e856659217
commit
3f17f672f2
|
@ -14,7 +14,7 @@ public class DataEstesa extends DataFormattata {
|
||||||
public String stringaFormattata() {
|
public String stringaFormattata() {
|
||||||
String data = "";
|
String data = "";
|
||||||
|
|
||||||
if(getGiorno() < 9) data += "0" + getGiorno();
|
if(getGiorno() < 10) data += "0" + getGiorno();
|
||||||
else data += getGiorno();
|
else data += getGiorno();
|
||||||
|
|
||||||
data += " ";
|
data += " ";
|
||||||
|
|
|
@ -31,11 +31,9 @@ public abstract class DataFormattata implements Comparable<DataFormattata> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(DataFormattata o) {
|
public int compareTo(DataFormattata o) {
|
||||||
if(anno >= o.getAnno() && mese >= o.getMese() && giorno > o.getGiorno()) {
|
if(this.anno != o.anno) return this.anno - o.anno;
|
||||||
return 1;
|
if(this.mese != o.mese) return this.mese - o.mese;
|
||||||
} else if(anno == o.getAnno() && mese == o.getMese() && giorno == o.getGiorno()) {
|
return this.giorno - o.giorno;
|
||||||
return 0;
|
|
||||||
} else return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,27 @@ public class DataNumerica extends DataFormattata {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stringaFormattata() {
|
public String stringaFormattata() {
|
||||||
String giornoFormattato = "";
|
/*String giornoFormattato = "";
|
||||||
String meseFormattato = "";
|
String meseFormattato = "";
|
||||||
//String annoFormattato = "";
|
|
||||||
|
|
||||||
if(getGiorno() < 9) giornoFormattato = "0" + getGiorno();
|
if(getGiorno() < 10) giornoFormattato = "0";
|
||||||
else giornoFormattato += getGiorno();
|
giornoFormattato += getGiorno();
|
||||||
|
|
||||||
if(getMese() < 9) meseFormattato = "0" + getMese();
|
if(getMese() < 10) meseFormattato = "0";
|
||||||
else meseFormattato += getMese();
|
meseFormattato += getMese();
|
||||||
|
|
||||||
return giornoFormattato + "/" + meseFormattato + "/" + getAnno();
|
return giornoFormattato + "/" + meseFormattato + "/" + getAnno();
|
||||||
|
*/
|
||||||
|
|
||||||
|
int g = getGiorno();
|
||||||
|
int m = getMese();
|
||||||
|
int a = getAnno();
|
||||||
|
|
||||||
|
String res = (g<10) ? "0"+g : ""+g;
|
||||||
|
res += "/";
|
||||||
|
res += (m<10) ? "0"+m : "" + m;
|
||||||
|
|
||||||
|
return res + a;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue