Package org.ocpsoft.rewrite.showcase.access

Source Code of org.ocpsoft.rewrite.showcase.access.TimerBean

package org.ocpsoft.rewrite.showcase.access;

import java.io.Serializable;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

import org.joda.time.DateTime;
import org.ocpsoft.pretty.time.PrettyTime;
import org.ocpsoft.pretty.time.units.Second;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
@Named
@SessionScoped
public class TimerBean implements Serializable
{
   private static final long serialVersionUID = 4702776314232622624L;

   public String getSecondsUntilGranted()
   {
      DateTime time = new DateTime();
      int secondsRemain = 60 - time.getSecondOfMinute();
      DateTime deniedTime = time.plusSeconds(secondsRemain);
      PrettyTime prettyTime = new PrettyTime();
      prettyTime.setUnits(new Second(prettyTime.getLocale()));
      return prettyTime.format(deniedTime.toDate());
   }

   public String getSecondsUntilDenied()
   {
      DateTime time = new DateTime();
      int secondsRemain = 30 - time.getSecondOfMinute();
      DateTime grantedTime = time.plusSeconds(secondsRemain);
      PrettyTime prettyTime = new PrettyTime();
      prettyTime.setUnits(new Second(prettyTime.getLocale()));
      return prettyTime.format(grantedTime.toDate());
   }
}
TOP

Related Classes of org.ocpsoft.rewrite.showcase.access.TimerBean

TOP
Copyright © 2018 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.