Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Gets the readable gtin.
     *
     * @param src the src
     * @return the readable gtin
     */
    public static String getReadableGtin(String src) {
        src = src.toUpperCase();
        if (src.length() < 1) {
            return "";
        }
        char c = src.charAt(0);
        if (src.length() < 15) {
            return src;
        }
        if (c == 'A') {
            return src.substring(15 - 8, src.length());
        }
        if (c == 'B') {
            return src.substring(15 - 12, src.length());
        }
        if (c == 'C') {
            return src.substring(15 - 13, src.length());
        }
        if (c == 'D') {
            return src.substring(15 - 14, src.length());
        }

        // 'Z'
        return src.substring(1);
    }
}