OSDN Git Service

NixNoteのUpgradeDbメソッドを不要部分を削除。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / filters / DateAttributeFilter.java
1 /*\r
2  * This file is part of NixNote/NeighborNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * \r
5  * This file may be licensed under the terms of of the\r
6  * GNU General Public License Version 2 (the ``GPL'').\r
7  *\r
8  * Software distributed under the License is distributed\r
9  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
10  * express or implied. See the GPL for the specific language\r
11  * governing rights and limitations.\r
12  *\r
13  * You should have received a copy of the GPL along with this\r
14  * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
15  * or write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
17  *\r
18 */\r
19 \r
20 package cx.fbn.nevernote.filters;\r
21 \r
22 import java.text.SimpleDateFormat;\r
23 \r
24 import com.evernote.edam.type.Note;\r
25 import com.trolltech.qt.core.QDateTime;\r
26 \r
27 public abstract class DateAttributeFilter extends AttributeFilter {\r
28     protected boolean checkSince;\r
29     private final boolean checkCreated;\r
30 \r
31     public DateAttributeFilter (boolean since, boolean created) {\r
32         super();\r
33         checkSince=since;\r
34         checkCreated=created;\r
35     }\r
36 \r
37     @Override\r
38         public abstract boolean attributeCheck(Note n);\r
39 \r
40     protected QDateTime noteTime(Note n) {\r
41         String dateTimeFormat = new String("MM/dd/yyyy HH:mm:ss");\r
42         SimpleDateFormat simple = new SimpleDateFormat(dateTimeFormat);\r
43 \r
44         if (checkCreated) {\r
45             StringBuilder creationDate = new StringBuilder(simple.format(n.getCreated()));\r
46             return QDateTime.fromString(creationDate.toString(), "MM/dd/yyyy HH:mm:ss");\r
47         } else {\r
48             StringBuilder updatedDate = new StringBuilder(simple.format(n.getUpdated()));\r
49             return QDateTime.fromString(updatedDate.toString(), "MM/dd/yyyy HH:mm:ss");\r
50         }\r
51     }\r
52 \r
53     protected QDateTime currentTime() {\r
54         return QDateTime.currentDateTime();\r
55     }\r
56 }\r