Created
July 16, 2014 00:16
-
-
Save kmb385/216bb1adbdf8f96b983b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
public class Artist { | |
String mNickname; | |
String mName; | |
String mDescription; | |
String mScene; | |
String mDay; | |
String mTime; | |
String mImageURL; | |
Date mDate; | |
public Artist(String mNickname, String mName, String mDescription, String mScene, String mDay, String mTime, | |
String mImageURL, Date mDate) { | |
super(); | |
this.mNickname = mNickname; | |
this.mName = mName; | |
this.mDescription = mDescription; | |
this.mScene = mScene; | |
this.mDay = mDay; | |
this.mTime = mTime; | |
this.mImageURL = mImageURL; | |
this.mDate = mDate; | |
} | |
public String getmNickname() { | |
return mNickname; | |
} | |
public void setmNickname(String mNickname) { | |
this.mNickname = mNickname; | |
} | |
public String getmName() { | |
return mName; | |
} | |
public void setmName(String mName) { | |
this.mName = mName; | |
} | |
public String getmDescription() { | |
return mDescription; | |
} | |
public void setmDescription(String mDescription) { | |
this.mDescription = mDescription; | |
} | |
public String getmScene() { | |
return mScene; | |
} | |
public void setmScene(String mScene) { | |
this.mScene = mScene; | |
} | |
public String getmDay() { | |
return mDay; | |
} | |
public void setmDay(String mDay) { | |
this.mDay = mDay; | |
} | |
public String getmTime() { | |
return mTime; | |
} | |
public void setmTime(String mTime) { | |
this.mTime = mTime; | |
} | |
public String getmImageURL() { | |
return mImageURL; | |
} | |
public void setmImageURL(String mImageURL) { | |
this.mImageURL = mImageURL; | |
} | |
public Date getDate() { | |
return mDate; | |
} | |
public void setmate(Date mDate) { | |
this.mDate = mDate; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Calendar; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class StackDemo { | |
public static void main(String[] args) { | |
Calendar cal = Calendar.getInstance(); | |
Artist artist = new Artist("FIRST", "FIRST", "Modern", "PA", "22", "22", "/test", cal.getTime() ); | |
cal.add(Calendar.DATE, 1); | |
Artist artist2 = new Artist("Second", "Second", "Modern", "PA", "22", "22", "/test", cal.getTime() ); | |
cal.add(Calendar.DATE, 1); | |
Artist artist3 = new Artist("Third", "Third", "Modern", "PA", "22", "22", "/test", cal.getTime() ); | |
cal.add(Calendar.DATE, 1); | |
Artist artist4 = new Artist("Fourth", "Fourth", "Modern", "PA", "22", "22", "/test", cal.getTime() ); | |
cal.add(Calendar.DATE, 1); | |
List<Artist> artists = new LinkedList<Artist>(); | |
artists.add(artist2); | |
artists.add(artist3); | |
artists.add(artist); | |
artists.add(artist4); | |
Collections.shuffle(artists); | |
System.out.println("Before Sort:"); | |
printArtists(artists); | |
System.out.println("After sort:"); | |
sortArrayByDate(artists); | |
printArtists(artists); | |
} | |
private static void printArtists(List<Artist> artists) { | |
for(Artist artist: artists){ | |
System.out.println(artist.getmName()); | |
} | |
} | |
static public void sortArrayByDate(List<Artist> list) { | |
Collections.sort(list, new Comparator<Artist>() { | |
@Override | |
public int compare(Artist lhs, Artist rhs) { | |
return lhs.getDate().compareTo(rhs.getDate()); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment