Package org.nextime.ion.common

Source Code of org.nextime.ion.common.IsOnline

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;
    }
  }

}
TOP

Related Classes of org.nextime.ion.common.IsOnline

TOP
Copyright © 2015 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.