Pregunta

I've got 2 Strings and both are the same:

alter follower  = 2014-02-23T18:41:35Z
neuster follower= 2014-02-23T18:41:35Z

I do an if/else so if they're the same the program should just display values and if not it should announce the new name (follower), but somehow, it's only doing the else statement when they're the same...

my code;

///////////////////
/// New Follower Trigger
/////////////////// 

if(followdateold.toLowerCase().equals(latestfollowerdate.toLowerCase())) {
    System.out.println("Noch kein neuer Follower... :( ");
    System.out.println("Noch kein neuer Follower... :( ");
}else{
    System.out.println("alter follower= "+followdateold);
    System.out.println("neuster follower= "+latestfollowerdate);
        sendMessage("#"+YBot.MyBot.ownerchannel+"", "Danke für deinen follow, "+fname);
        FollowerChecker.Writer();

        try {
            FollowerChecker.readFile("donottouch.txt");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
¿Fue útil?

Solución

Its possible that there are some leading or trailing whitespaces in the 2 strings, you should trim the whitespace before comparing the strings, try this :

if(followdateold.trim().toLowerCase().equals(latestfollowerdate.trim().toLowerCase())) {

Otros consejos

Try using

followdateold.equalsIgnoreCase(latestfollowerdate)

maybe that would work.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top