package org.nextime.ion.common;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.nextime.ion.framework.business.Publication;
public class IsOnline {
public static boolean getStatus(Publication p) {
if (p.getState().equals("P_P"))
return true;
if (p.getState().equals("P_D")) {
Date now = new Date();
try {
Date begin =
new SimpleDateFormat("dd/MM/yyyy").parse(
p.getMetaData("dateBegin") + "");
Date end =
new SimpleDateFormat("dd/MM/yyyy").parse(
p.getMetaData("dateEnd") + "");
if (now.after(begin) && now.before(end))
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
return false;
}
public static boolean getStatus(Object p) {
try {
return getStatus((Publication)p);
}
catch( Exception e ) {
return false;
}
}
}