Package org.goda.chronic.handlers

Source Code of org.goda.chronic.handlers.SmSyHandler

package org.goda.chronic.handlers;


import java.util.List;
import org.goda.chronic.Options;
import org.goda.chronic.tags.ScalarMonth;
import org.goda.chronic.tags.ScalarYear;
import org.goda.chronic.utils.Time;
import org.goda.chronic.utils.Token;
import org.goda.time.DateTime;
import org.goda.time.MutableInterval;

public class SmSyHandler implements IHandler {
  public MutableInterval handle(List<Token> tokens, Options options) {
    int month = tokens.get(0).getTag(ScalarMonth.class).getType().intValue();
    int year = tokens.get(1).getTag(ScalarYear.class).getType().intValue();
    MutableInterval MutableInterval;
    try {
      DateTime start = Time.construct(year, month);
      DateTime end = Time.cloneAndAdd(start, Time.MONTH, 1);
      MutableInterval = new MutableInterval(start, end);
    }
    catch (IllegalArgumentException e) {
      if (options.isDebug()) {
        e.printStackTrace(System.out);
      }
      MutableInterval = null;
    }
    return MutableInterval;
  }

}
TOP

Related Classes of org.goda.chronic.handlers.SmSyHandler

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.