
com.jk.time.JKTimeObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jk-util Show documentation
Show all versions of jk-util Show documentation
This is utility classes used by my other projects.
package com.jk.time;
import java.util.Calendar;
import java.util.Date;
public class JKTimeObject {
private int year;
private int month;
private int day;
private int hour;
private int munite;
public JKTimeObject() {
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getMunite() {
return munite;
}
public void setMunite(int munite) {
this.munite = munite;
}
public JKTimeObject toTimeObject(Date date,Date time) {
JKTimeObject fsTimeObject = new JKTimeObject();
Calendar timeInstance = Calendar.getInstance();
timeInstance.setTimeInMillis(time.getTime());
fsTimeObject.setHour(timeInstance.get(Calendar.HOUR_OF_DAY));
fsTimeObject.setMunite(timeInstance.get(Calendar.MINUTE));
Calendar dateInstance = Calendar.getInstance();
dateInstance.setTime(date);
fsTimeObject.setYear(dateInstance.get(Calendar.YEAR));
fsTimeObject.setMonth(dateInstance.get(Calendar.MONTH));
fsTimeObject.setDay(dateInstance.get(Calendar.DAY_OF_MONTH));
return fsTimeObject;
}
public boolean after(JKTimeObject thareTime) {
if(getYear() == thareTime.getYear() || thareTime.getYear() > getYear()){
System.out.println("after:: Year true");
if(thareTime.getMonth() < getMonth()){
return true;
}
if(getMonth() == thareTime.getMonth()){
System.out.println("after:: Month true");
if(thareTime.getDay() < getDay()){
System.out.println("after:: Day true");
return true;
}
if(getDay() == thareTime.getDay()){
if(getHour() == thareTime.getHour()){
if(thareTime.getMunite() thareTime.getHour()) {
return true;
}
}
}
}
return false;
}
public boolean before(JKTimeObject thareTime) {
if(getYear() == thareTime.getYear() || thareTime.getYear() > getYear()){
if(getMonth() == thareTime.getMonth() || thareTime.getMonth() > getMonth()){
if(thareTime.getMonth() > getMonth()){
return true;
}
if(thareTime.getDay() > getDay()){
return true;
}
if(getDay() == thareTime.getDay()){
if(getHour() == thareTime.getHour()){
if(getMunite()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy