Home / Function/ tryParseTime() — netty Function Reference

tryParseTime() — netty Function Reference

Architecture documentation for the tryParseTime() function in DateFormatter.java from the netty codebase.

Function java Buffer Allocators calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  e7591c3e_834f_5798_5679_8e0c60fc675a["tryParseTime()"]
  868307e6_8dd7_9eb3_bb13_ca685c4d59cf["DateFormatter"]
  e7591c3e_834f_5798_5679_8e0c60fc675a -->|defined in| 868307e6_8dd7_9eb3_bb13_ca685c4d59cf
  ccbf0bfc_8853_892e_8582_30ad6041b06a["parseToken()"]
  ccbf0bfc_8853_892e_8582_30ad6041b06a -->|calls| e7591c3e_834f_5798_5679_8e0c60fc675a
  f6218a9b_85e0_505c_17e2_64f08857d3eb["isDigit()"]
  e7591c3e_834f_5798_5679_8e0c60fc675a -->|calls| f6218a9b_85e0_505c_17e2_64f08857d3eb
  c92994fa_0cd5_d7c9_02dd_596787c21993["getNumericalValue()"]
  e7591c3e_834f_5798_5679_8e0c60fc675a -->|calls| c92994fa_0cd5_d7c9_02dd_596787c21993
  style e7591c3e_834f_5798_5679_8e0c60fc675a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-base/src/main/java/io/netty/handler/codec/DateFormatter.java lines 180–242

    private boolean tryParseTime(CharSequence txt, int tokenStart, int tokenEnd) {
        int len = tokenEnd - tokenStart;

        // h:m:s to hh:mm:ss
        if (len < 5 || len > 8) {
            return false;
        }

        int localHours = -1;
        int localMinutes = -1;
        int localSeconds = -1;
        int currentPartNumber = 0;
        int currentPartValue = 0;
        int numDigits = 0;

        for (int i = tokenStart; i < tokenEnd; i++) {
            char c = txt.charAt(i);
            if (isDigit(c)) {
                currentPartValue = currentPartValue * 10 + getNumericalValue(c);
                if (++numDigits > 2) {
                  return false; // too many digits in this part
                }
            } else if (c == ':') {
                if (numDigits == 0) {
                    // no digits between separators
                    return false;
                }
                switch (currentPartNumber) {
                    case 0:
                        // flushing hours
                        localHours = currentPartValue;
                        break;
                    case 1:
                        // flushing minutes
                        localMinutes = currentPartValue;
                        break;
                    default:
                        // invalid, too many :
                        return false;
                }
                currentPartValue = 0;
                currentPartNumber++;
                numDigits = 0;
            } else {
                // invalid char
                return false;
            }
        }

        if (numDigits > 0) {
            // pending seconds
            localSeconds = currentPartValue;
        }

        if (localHours >= 0 && localMinutes >= 0 && localSeconds >= 0) {
            hours = localHours;
            minutes = localMinutes;
            seconds = localSeconds;
            return true;
        }

        return false;
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does tryParseTime() do?
tryParseTime() is a function in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/DateFormatter.java.
Where is tryParseTime() defined?
tryParseTime() is defined in codec-base/src/main/java/io/netty/handler/codec/DateFormatter.java at line 180.
What does tryParseTime() call?
tryParseTime() calls 2 function(s): getNumericalValue, isDigit.
What calls tryParseTime()?
tryParseTime() is called by 1 function(s): parseToken.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free