-
-
Save anonymous/df0c03e98415f058f192 to your computer and use it in GitHub Desktop.
daydiffbean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.ibi.jsf.beans.user; | |
import java.io.Serializable; | |
import java.util.Date; | |
import javax.faces.bean.ManagedBean; | |
import javax.faces.bean.SessionScoped; | |
import org.primefaces.event.SelectEvent; | |
@ManagedBean(name="dayDiffBean") | |
@SessionScoped | |
public class DayDiffBean implements Serializable { | |
/** | |
* | |
*/ | |
private static final long serialVersionUID = 1L; | |
private Date from; | |
private Date to; | |
private String diff=""; | |
private final long oneDay=1000*60*60*24; | |
public void fromSelected(SelectEvent event){ | |
from=(Date) event.getObject(); | |
calDiff(); | |
} | |
public void toSelected(SelectEvent event){ | |
to=(Date) event.getObject(); | |
calDiff(); | |
} | |
public void calDiff(){ | |
if(from==null||to==null){ | |
diff="N/A"; | |
return; | |
} | |
diff=(to.getTime()-from.getTime())/oneDay+""; | |
} | |
public String getDiff() { | |
return diff; | |
} | |
public void setDiff(String diff) { | |
this.diff = diff; | |
} | |
public void setFrom(Date from) { | |
this.from = from; | |
} | |
public Date getFrom() { | |
return from; | |
} | |
public Date getTo() { | |
return to; | |
} | |
public void setTo(Date to) { | |
this.to = to; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment