PageRenderTime 262ms CodeModel.GetById 90ms app.highlight 3ms RepoModel.GetById 118ms app.codeStats 0ms

/src/main/java/com/google/ie/common/comparator/ProjectCreationDateComparator.java

http://thoughtsite.googlecode.com/
Java | 41 lines | 12 code | 7 blank | 22 comment | 0 complexity | 02a6f76c46855769c4c7e950db12ad8c MD5 | raw file
 1/* Copyright 2010 Google Inc.
 2 * 
 3 * Licensed under the Apache License, Version 2.0 (the "License");
 4 * you may not use this file except in compliance with the License.
 5 * You may obtain a copy of the License at
 6 * 
 7 *      http://www.apache.org/licenses/LICENSE-2.0
 8 * 
 9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS.
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License
14 */
15
16package com.google.ie.common.comparator;
17
18import com.google.ie.business.domain.Project;
19
20import java.util.Comparator;
21import java.util.Date;
22
23/**
24 * Comparator class to compare the project based on their creation date.
25 * 
26 * @author Charanjeet singh
27 * 
28 */
29public class ProjectCreationDateComparator implements Comparator<Project> {
30
31    @Override
32    public int compare(Project project1, Project project2) {
33        Date creationDate1 = project1.getCreatedOn();
34        Date creationDate2 = project2.getCreatedOn();
35        // Multiplying the result of date comparison to sort the dates in
36        // descending order.
37        return (-1 * creationDate1.compareTo(creationDate2));
38    }
39
40}
41