Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Extracts a GTIN from a GS1 DataMatrix formatted bar code.
     *
     * @param code
     *         the raw bar code value
     * @return the extracted GTIN or null if none found
     */
    public static String extractFromDataMatrix(String code) {
        if (code.length() < 16) {
            return null;
        }
        if (code.startsWith("01")) {
            return code.substring(2, 16);
        }
        return null;
    }
}