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

  • SEARCH
  • Home
  • 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 7081259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:53:51+00:00 2026-05-28T06:53:51+00:00

Long story short, the snippets below is about converting the texted month to numbered

  • 0

Long story short, the snippets below is about converting the texted month to numbered month (ex, Jan -> 1). There’s no error but in the end I keep getting 0 as the result of m. Where’s the problem?

//date1s[] is the result of splitting date1 by spaces (date1 = 1 Jan 2012)
m = convertMonth(date1s[1]); //date1s[1] contains the Month; date1s[0] the date and date1s[2] the year

public int convertMonth(String monw) {
        int x = 0;
        if (monw == "Jan") {
            x = 1;
        }
        else if (monw == "Feb") {
            x = 2;
        } 
        else if (monw == "Mar") {
            x = 3;
        } 
        else if (monw == "Apr") {
            x = 4;
        } 
        else if (monw == "May") {
            x = 5;
        } 
        else if (monw == "Jun") {
            x = 6;
        } 
        else if (monw == "Jul") {
            x = 7;
        } 
        else if (monw == "Aug") {
            x = 8;
        } 
        else if (monw == "Sep") {
            x = 9;
        } 
        else if (monw == "Oct") {
            x = 10;
        } 
        else if (monw == "Nov") {
            x = 11;
        } 
        else if (monw == "Dec") {
            x = 12;
        }
        return x;
}    
  • 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-05-28T06:53:52+00:00Added an answer on May 28, 2026 at 6:53 am

    Use the .equals() method of String.

    if (monw.equals("Jan"))

    When you use == operator, it compares the memory locations of the two objects and returns false. In other words, it only returns true if the same object is on both sides of equation. So you should use the .equals() method instead, which returns true if two different objects have the same value.

    EDIT:
    I just checked, @LazyCubicleMonkey is right. The == operator checks if locations in memory are the same. I created a class, overrided the hashCode() method, created two objects and printed obj1==obj2. It prints false.

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

Sidebar

Related Questions

Long story short, when I submit a form, there are error messages under each
Long story short: I used reflector on the System.Security.Util.Tokenizer class, and there's loads of
Long story short, I have a struct (see below) that contains exactly one field:
Long story short: # this works as expected: logging.error(my_object.__unicode__()) # this doesn't: logging.error(my_object) Same
Long story short, here's what i'm going to be trying to do: There is
Long story short: I've been layout out UI's with Html/CSS for about 8 years
Long story short I'm curious if there is any way to pull the the
Long story short, I essentially created a branch of development within our trunk. About
Long story short I am checking a rather lengthy error log. I would like
Long story short, we found files promoting prescription drugs on our server that we

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.