Created
May 11, 2016 02:14
-
-
Save beeender/13e149a073c19164415ea571c404cc80 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
@Test | |
public void dateSort() { | |
Date d20160127 = new GregorianCalendar(2016, Calendar.JANUARY, 27).getTime(); | |
Date d20160227 = new GregorianCalendar(2016, Calendar.FEBRUARY, 27).getTime(); | |
Date d20160510 = new GregorianCalendar(2016, Calendar.MAY, 10).getTime(); | |
Date d20160527 = new GregorianCalendar(2016, Calendar.MAY, 27).getTime(); | |
Date begin = new GregorianCalendar(2016, Calendar.JANUARY, 1).getTime(); | |
Date end = new GregorianCalendar(2016, Calendar.FEBRUARY, 29).getTime(); | |
realm.beginTransaction(); | |
AllTypes allTypes = realm.createObject(AllTypes.class); | |
allTypes.setColumnDate(d20160127); | |
allTypes = realm.createObject(AllTypes.class); | |
allTypes.setColumnDate(d20160227); | |
allTypes = realm.createObject(AllTypes.class); | |
allTypes.setColumnDate(d20160510); | |
allTypes = realm.createObject(AllTypes.class); | |
allTypes.setColumnDate(d20160527); | |
realm.commitTransaction(); | |
RealmResults<AllTypes> results = realm.where(AllTypes.class).between(AllTypes.FIELD_DATE, begin, end).findAll(); | |
assertEquals(results.size(), 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment