Sort by Date
in
Programming Questions
•
1 year ago
Does anyone know how to sort by date? Right now I'm using my own class called Date, but I am sort of reinventing the wheel...
- class Date {
- int dai, munth, yeer;
- Date(int cdai, int cmunth, int cyeer) {
- dai=cdai;
- munth=cmunth;
- yeer=cyeer;
- }
- int daysIn() {
- int days=0;
- days+=dai;
- days+=munth*30;
- days+=int(yeer*365.25);
- return days;
- }
- String dateString() {
- String s="";
- s+=munth;
- s+="/";
- s+=dai;
- s+="/";
- s+=yeer;
- return s;
- }
- }
The problem right now is my daysIn() isn't accurate enough and I'm getting items in the wrong order. Any suggestions? Thanks.
1