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() {
|
||||
String data = "";
|
||||
|
||||
if(getGiorno() < 9) data += "0" + getGiorno();
|
||||
if(getGiorno() < 10) data += "0" + getGiorno();
|
||||
else data += getGiorno();
|
||||
|
||||
data += " ";
|
||||
|
@ -31,11 +31,9 @@ public abstract class DataFormattata implements Comparable<DataFormattata> {
|
||||
|
||||
@Override
|
||||
public int compareTo(DataFormattata o) {
|
||||
if(anno >= o.getAnno() && mese >= o.getMese() && giorno > o.getGiorno()) {
|
||||
return 1;
|
||||
} else if(anno == o.getAnno() && mese == o.getMese() && giorno == o.getGiorno()) {
|
||||
return 0;
|
||||
} else return -1;
|
||||
if(this.anno != o.anno) return this.anno - o.anno;
|
||||
if(this.mese != o.mese) return this.mese - o.mese;
|
||||
return this.giorno - o.giorno;
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,17 +12,27 @@ public class DataNumerica extends DataFormattata {
|
||||
|
||||
@Override
|
||||
public String stringaFormattata() {
|
||||
String giornoFormattato = "";
|
||||
/*String giornoFormattato = "";
|
||||
String meseFormattato = "";
|
||||
//String annoFormattato = "";
|
||||
|
||||
if(getGiorno() < 9) giornoFormattato = "0" + getGiorno();
|
||||
else giornoFormattato += getGiorno();
|
||||
if(getGiorno() < 10) giornoFormattato = "0";
|
||||
giornoFormattato += getGiorno();
|
||||
|
||||
if(getMese() < 9) meseFormattato = "0" + getMese();
|
||||
else meseFormattato += getMese();
|
||||
if(getMese() < 10) meseFormattato = "0";
|
||||
meseFormattato += getMese();
|
||||
|
||||
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…
x
Reference in New Issue
Block a user