Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8239413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:08:21+00:00 2026-06-07T20:08:21+00:00

e have a date form that can accept 2 or 4 digit years. I

  • 0

e have a date form that can accept 2 or 4 digit years. I am not trying to code for exceptions…just instances where the year is either 2 or 4 digits long. I’m using lastIndexOf to find the last instance of “/”, and if the third character after the slash is numeric, I assume a 4-digit year. Otherwise it’s a two digit year.

I’ve already tested and validated that this is the only line giving me an issue right now,

if (inputLine.lastIndexOf.isNumeric("/"))+3 {
   year = inputLine.trim().substring(inputLine.lastIndexOf("/")+1,input.lastIndexOf("/")+4).trim);
   else year = "0000";

I keep getting compilation errors. For the lines in which I’m adding to the index Value, I’ve got a bad operand for the binary operator. Additionally, the variable lastIndexOf can’t be found.

I’m calling the list below at the head of the program, and as far as I can tell from the java documentation, io and lang pull in the appropriate methods and classes.

import java.util.*;
import java.io.*;
import java.nio.file.*;
import java.lang.*;

For the if statement, although my parens are balanced, I don’t know if adding the additional characters (e.g., index value + 3) is being done within the right level of the nested parens. That being said, I’ve tried top add those integers pretty much to no avail.

if (inputLine.lastIndexOf.isNumeric("/"))+3 {
   year = inputLine.trim().substring(inputLine.lastIndexOf("/")+1,input.lastIndexOf("/")+4).trim);
   else year = "00/00/0000";

I’m wondering a couple thigs: First, can I do this in a single statement, or is it better to define the index in one statement, then define index+offset-value in a subsequent statement?

When I’m using multiple methods and classes operating on a single field (e.g., .trim().substring.Indexof() etc., what is the order in which Java parses those? I’d like to undestand how these statements are being parsed so I’ve got a better understanding of the best way to manipulate the variables and test the output.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:08:23+00:00Added an answer on June 7, 2026 at 8:08 pm

    You are using the +3 incorrectly. You’re putting it outside of the if(condition) statement, somewhere where it doesn’t make any syntactic sense – it’s gobbledygook in your code.

    Also, if you’re trying to test if the result of inputline.lastIndexOf(‘/’) is numeric, it won’t mean anything. If the specified character does not occur, lastIndexOf won’t throw an exception; it will just return -1. You want to test if the result is greater than/equal to zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that allows users to enter a date of birth: ie:
I have a date string of the form '2009/05/13 19:19:30 -0400'. It seems that
I have a web app with a form that I am trying to pass
I have a form that when the person selects the date I want the
I have a form where the user can select a date. I would like
I have a form with a field that uses a date/time picker which produces
I currently have a form that let's you set the date for an event.
Hi everyone I have a form that accepts user date entry in the form
I have about 20 text fields on a form that a user can fill
I've have a date field in my table that stores dates from a form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.