Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static boolean isToday(Calendar cal) {
        boolean ret = false;
        Calendar tmp = Calendar.getInstance();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String s1 = format.format(cal.getTime());
        String s2 = format.format(tmp.getTime());
        if (s1.equals(s2)) {
            ret = true;
        }
        return ret;
    }

    public static boolean isToday(String s1) {
        boolean ret = false;
        Calendar tmp = Calendar.getInstance();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String s2 = format.format(tmp.getTime());
        if (s1.equals(s2)) {
            ret = true;
        }
        return ret;
    }
}