finished basic account add
[Bookkeeping.git] / src / com / interrupt / util / DateUtil.java
blob0577f13b71570cddb1cf94e8528eb459da684388
1 package com.interrupt.util;
3 import java.text.ParseException;
4 import java.text.SimpleDateFormat;
5 import java.util.Date;
7 public class DateUtil {
10 private static String format_s = null;
11 private static SimpleDateFormat dformat = null;
12 static {
14 format_s = "MM/dd/yyyy HH:mm:ss z";
15 dformat = new SimpleDateFormat( format_s );
19 public static boolean before( String before_s, String after_s ) {
22 boolean isbefore = false;
23 Date date1 = null;
24 Date date2 = null;
25 try {
27 date1 = dformat.parse( before_s );
28 date2 = dformat.parse( after_s );
30 isbefore = date1.before(date2);
33 catch( ParseException e ) {
35 e.printStackTrace();
37 return isbefore;
41 public static boolean after( String after_s, String before_s ) {
44 boolean isbefore = false;
45 Date date1 = null;
46 Date date2 = null;
47 try {
49 date1 = dformat.parse( after_s );
50 date2 = dformat.parse( before_s );
52 isbefore = date1.after(date2);
55 catch( ParseException e ) {
57 e.printStackTrace();
59 return isbefore;
64 public static boolean equals( String date_1, String date_2 ) {
67 boolean isequals = false;
68 Date date1 = null;
69 Date date2 = null;
70 try {
72 date1 = dformat.parse( date_1 );
73 date2 = dformat.parse( date_2 );
75 isequals = date1.equals(date2);
78 catch( ParseException e ) {
80 e.printStackTrace();
82 return isequals;