Java Today isGreaterThanToday(String dateString)

Here you can find the source of isGreaterThanToday(String dateString)

Description

is Greater Than Today

License

Open Source License

Declaration

public static boolean isGreaterThanToday(String dateString) 

Method Source Code

//package com.java2s;
/**/*from w w w. ja  va  2 s .c o  m*/
 * Created on Aug 9, 2004
 *
 * Copyright 2005 by Arysys Technologies (P) Ltd.,
 * #3,Shop line,
 * Sasmira Marg,
 * Worli,Mumbai 400 025
 * India
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Arysys Technologies (P) Ltd. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Arysys Technologies (P) Ltd.
 *
 */

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static boolean isGreaterThanToday(String dateString) {
        try {
            if (dateString.trim().length() < 12) {
                dateString += " 00:00:00";
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date dueDate = sdf.parse(dateString);
            GregorianCalendar calendar = new GregorianCalendar();
            Date today = calendar.getTime();
            if (dueDate.getTime() < today.getTime()) {
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public static long getTime(String dateTimeString) {
        long time = 0;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = sdf.parse(dateTimeString);
            time = date.getTime();
        } catch (Exception e) {
            e.printStackTrace();
            time = 0;
        }
        return time;
    }
}

Related

  1. getTommorrow(String today)
  2. getYestoday()
  3. getYestoday(String sourceDate, String format)
  4. isBeforeToday(Date date)
  5. isBeforeToday(Date date)
  6. isToday(Date d1)
  7. isToday(Date date)
  8. isToday(Date date)
  9. isToday(Date date, TimeZone timezone)