Java Timestamp isSameMonth(Timestamp t1, Timestamp t2)

Here you can find the source of isSameMonth(Timestamp t1, Timestamp t2)

Description

is Same Month

License

Open Source License

Declaration

public static boolean isSameMonth(Timestamp t1, Timestamp t2) 

Method Source Code


//package com.java2s;
import java.sql.Timestamp;

import java.util.Calendar;

public class Main {

    public static boolean isSameMonth(Timestamp t1, Timestamp t2) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(t1);/* w  w w .  j a v a2 s .  c  om*/
        int year1 = cal.get(Calendar.YEAR);
        int month1 = cal.get(Calendar.MONTH);
        System.out.println("year1:" + year1 + "month1:" + month1);
        cal.setTime(t2);
        int year2 = cal.get(Calendar.YEAR);
        int month2 = cal.get(Calendar.MONTH);
        System.out.println("year2:" + year2 + "month2:" + month2);
        if (year1 == year2 && month1 == month2)
            return true;
        return false;
    }
}

Related

  1. isDST(Timestamp ts)
  2. isInPast(Timestamp timeStamp)
  3. isLongDate(Timestamp date)
  4. isLongTerm(Timestamp oldTime, Timestamp newTime)
  5. isSameDay(Timestamp one, Timestamp two)
  6. IsTechStatisticWorkTime(Timestamp timestamp)
  7. isTimeStamp(Class o)
  8. isTimestamp(String aS_DateTime, String aS_Format)
  9. isTimestamp(String str)