Example usage for java.lang Long parseLong

List of usage examples for java.lang Long parseLong

Introduction

In this page you can find the example usage for java.lang Long parseLong.

Prototype

public static long parseLong(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal long .

Usage

From source file:org.activiti.rest.api.cycle.ArtifactGet.java

@Override
protected void executeWebScript(WebScriptRequest req, Status status, Cache cache, Map<String, Object> model) {
    String artifactId = getString(req, "artifactId");
    // TODO: add service to retrieve artifacts by id

    long id = Long.parseLong(artifactId);

    model.put("artifact",
            new Artifact(id, id == 1 ? "http://jorambarrez.be/files/blog/bpmn2_sneakpeek/vacationRequest.png"
                    : "http://www.jorambarrez.be/files/blog/jbpm_43_released/jbpm_evolution.png"));
}

From source file:com.netscape.certsrv.util.DateAdapter.java

public Date unmarshal(String value) throws Exception {
    return StringUtils.isEmpty(value) ? null : new Date(Long.parseLong(value));
}

From source file:bankingclient.TaoTaiKhoanFrame.java

public TaoTaiKhoanFrame(NewOrOldAccFrame acc) {

    initComponents();//from   w  ww  .  j  av  a  2s .  co  m
    this.jText_ten_tk.setText("");
    this.jText_sd.setText("");

    this.noAcc = acc;
    this.mainCustomerName = null;
    this.setVisible(false);

    jBt_ht.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (NumberUtils.isNumber(jText_sd.getText()) && (Long.parseLong(jText_sd.getText()) > 0)) {
                try {
                    Socket client = new Socket("113.22.46.207", 6013);
                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(3);
                    dout.writeUTF(jText_ten_tk.getText() + "\n" + mainCustomerName + "\n" + jText_sd.getText());
                    dout.flush();
                    DataInputStream din = new DataInputStream(client.getInputStream());
                    byte check = din.readByte();
                    if (check == 1) {
                        JOptionPane.showMessageDialog(rootPane, "da tao tai khoan thanh cong");
                    } else {
                        JOptionPane.showMessageDialog(rootPane, "tao tai khoan khong thanh cong");
                    }
                    client.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                noAcc.setVisible(true);
                TaoTaiKhoanFrame.this.setVisible(false);
            } else {
                JOptionPane.showMessageDialog(rootPane, "Can nhap lai so tien gui");
            }

        }
    });
    jBt_ql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            noAcc.setVisible(true);
            TaoTaiKhoanFrame.this.setVisible(false);

        }
    });
}

From source file:org.ext4spring.parameter.converter.simple.LongConverter.java

@Override
public <T> T toTypedValue(String stringValue, Class<T> type) {
    return (stringValue != null) ? type.cast(Long.parseLong(stringValue)) : null;
}

From source file:com.omertron.yamjtrakttv.tools.CompleteMoviesTools.java

/**
 * Parse the video element and extract the information from it.
 *
 * @param eVideo//from   w  w  w .  ja va  2s . c  o m
 * @return
 */
public static Video parseVideo(Element eVideo) {
    Video v = new Video();
    v.setTitle(DOMHelper.getValueFromElement(eVideo, "title"));
    v.setYear(DOMHelper.getValueFromElement(eVideo, "year"));
    v.setType(DOMHelper.getValueFromElement(eVideo, "movieType"));
    v.setWatched(Boolean.parseBoolean(DOMHelper.getValueFromElement(eVideo, "watched")));

    String stringDate = DOMHelper.getValueFromElement(eVideo, "watchedDate");
    if (StringUtils.isNumeric(stringDate) && !"0".equals(stringDate)) {
        v.setWatchedDate(new Date(Long.parseLong(stringDate)));
    } else {
        LOG.debug("Invalid watched date '" + stringDate + "' using current date");
        v.setWatchedDate(new Date());
        // Because the date was set by us, let's add a small (1 second) delay to ensure that we don't get identical watched dates
        try {
            TimeUnit.SECONDS.sleep(DEFAULT_DELAY);
        } catch (InterruptedException ex) {
            // Don't care if we are interrupted or not.
        }
    }

    NodeList nlID = eVideo.getElementsByTagName("id");
    if (nlID.getLength() > 0) {
        Node nID;
        Element eID;
        for (int loop = 0; loop < nlID.getLength(); loop++) {
            nID = nlID.item(loop);
            if (nID.getNodeType() == Node.ELEMENT_NODE) {
                eID = (Element) nID;
                String moviedb = eID.getAttribute("movieDatabase");
                if (StringUtils.isNotBlank(moviedb)) {
                    v.addId(moviedb, eID.getTextContent());
                }
            }
        }
    }

    // TV specific processing
    if (v.isTvshow()) {
        v.addEpisodes(parseTvFiles(eVideo));
    }

    return v;
}

From source file:ispok.helper.VisitorLazyDataModel.java

@Override
public VisitorDto getRowData(String rowKey) {
    return visitorService.getVisitorById(Long.parseLong(rowKey));
}

From source file:com.judoscript.jamaica.MyUtils.java

public static Object parseIntObject(String x, String typeHint) {
    boolean isLong = x.endsWith("l") || x.endsWith("L");
    if (isLong) {
        x = x.substring(0, x.length() - 1);
        if (typeHint == null)
            typeHint = "long";
    }/*  w  w w  . j  a  va2  s  .com*/

    long l;
    try {
        if (x.charAt(0) != '0') {
            l = Long.parseLong(x); // Decimal
        } else if (x.length() == 1) {
            l = 0;
        } else {
            char ch = x.charAt(1); // if exceptions, it's 0 anyway.
            if ((ch == 'x') || (ch == 'X'))
                l = Long.parseLong(x.substring(2), 16); // Hex
            else
                l = Long.parseLong(x, 8); // Octal
        }
    } catch (Exception e) {
        l = 0;
    }

    if (typeHint != null)
        return number2object(l, typeHint);
    else if (isLong)
        return new Long(l);
    else
        return new Integer((int) l);
}

From source file:com.qagen.osfe.core.utils.BeanPopulator.java

public static Object getValueAsType(String name, String value, String type, String format) {
    if ((value != null) && (value.trim().length() == 0)) {
        return null;
    }//  w w w  .  j a  va2  s . c o  m

    if (type.equals(AttributeType.String.name())) {
        return value;
    }

    if (type.equals(AttributeType.Integer.name())) {
        return Integer.parseInt(value);
    }

    if (type.equals(AttributeType.Float.name())) {
        return Float.parseFloat(value);
    }

    if (type.equals(AttributeType.Double.name())) {
        return Double.parseDouble(value);
    }

    if (type.equals(AttributeType.Boolean.name())) {
        return Boolean.parseBoolean(value);
    }

    if (type.equals(AttributeType.Date.name())) {
        return getDate(name, value, format);
    }

    if (type.equals(AttributeType.Time.name())) {
        return getTime(name, value, format);
    }

    if (type.equals(AttributeType.Long.name())) {
        return Long.parseLong(value);
    }

    if (type.equals(AttributeType.Timestamp.name())) {
        return getTimestamp(name, value, format);
    }

    if (type.equals(AttributeType.Object.name())) {
        return Timestamp.valueOf(value);
    }

    final String message = "The value type, " + type + " is not a defined type.  "
            + "You may need to extend the RowParser class and override the method, getValueAsType().";
    throw new FeedErrorException(message);
}

From source file:com.inkubator.hrm.web.converter.OrgTypeOfSpecListConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if (!StringUtils.isNumeric(value)) {
        return null;
    }/*from   w  w w . ja  va 2  s .co m*/
    OrgTypeOfSpecListService orgTypeOfSpecListService = (OrgTypeOfSpecListService) ServiceWebUtil
            .getService("orgTypeOfSpecListService");
    Object object = null;
    try {
        Long id = Long.parseLong(value);
        //            OccupationType occupationType = occupationTypeService.getEntiyByPK(id);
        object = orgTypeOfSpecListService.getEntiyByPK(id);
        return object;
    } catch (Exception e) {
        e.printStackTrace();
        throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
                "Error when converting to EmpData using EmpDataConverter", ""));
    }
}

From source file:RendererUtils.java

public static long getSizeInBytes(Path path) throws IOException {
    if (isValue(path))
        return Files.size(path);
    if (!isReference(path))
        throw new IllegalArgumentException("Path is not a value or reference");

    URL url = getReference(path).toURL();
    switch (url.getProtocol().toLowerCase()) {
    case "http":
    case "https":
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("HEAD");
        conn.connect();/*www .  j a va2  s  .  co  m*/
        String contentLength = conn.getHeaderField("Content-Length");
        conn.disconnect();
        if (contentLength != null && !contentLength.isEmpty())
            return Long.parseLong(contentLength);
        return -1;
    case "file":
        return FileUtils.toFile(url).length();
    default:
        return -1;
    }
}