Java Code Examples for

The following are Jave code examples for showing how to use tryParse() of the class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: appinventor-extensions   File:   Source Code and License Vote up 6 votes
public static Component valueOf(String text) {
  String[] parts = text.split(DELIM);
  if (parts.length != 4) {
    throw new IllegalArgumentException("text should have 4 parts.");

  Long id = Longs.tryParse(parts[0]);
  String authorId = parts[1];
  String fullyQualifiedName = parts[2];
  Long version = Longs.tryParse(parts[3]);
  if (id == null) {
    throw new IllegalArgumentException("id is not parsable.");
  if (version == null) {
    throw new IllegalArgumentException("version is not parsable.");

  return new Component(id, authorId, fullyQualifiedName, version);
Example 2
Project: OfficeAutomation   File:   Source Code and License Vote up 5 votes
public static Long getLong(Cell cell) {
    if (isNullCell(cell)) {
        return null;
    if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
        return (long) cell.getNumericCellValue();
    if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
        return Longs.tryParse(cell.getStringCellValue());
    throw new RuntimeException("can not convertWithConstructor cell value to Long!");