ResistSetupAction.java

package com.mycim.webapp.actions;

import com.mycim.framework.context.spring.SpringContext;
import com.mycim.server.resist.service.ResistService;

public class ResistSetupAction extends AbstractAction {

    protected ResistService resistService = SpringContext.getBean(ResistService.class);

    protected Integer convertTime(String time) {
        long secs = 0;
        int i;
        int j;
        boolean negative;
        if (time == null) {
            return 0;
        }
        if (time.trim().equalsIgnoreCase("")) {
            return 0;
        }
        time = time.trim();
        negative = false;
        if (time.substring(0, 1).equalsIgnoreCase("-")) {
            negative = true;
            time = time.substring(1);
        }
        i = time.indexOf(":");
        secs = Integer.parseInt(time.substring(0, i).trim()) * 3600;
        j = time.indexOf(":", i + 1);
        secs += (Integer.parseInt(time.substring(i + 1, j).trim()) * 60);
        secs += Integer.parseInt(time.substring(j + 1).trim());
        if (negative) {
            secs = -secs;
        }
        return new Integer((int) secs);
    }

}