Java does impart some brain damage, after all
-
Long before Apple started touting Night Shift, there was a similar feature baked into the CyanogenMod Android, called LiveDisplay. I'm a happy user of it, but recently it started working funny, warming display colors in the midday, and going all cold white in the night.
I wondered whether the ROM maintainer did something that broke it, then stopped caring for it because my main phone is an iPhone now. But last night I discovered why it stopped working properly. All it took for me was change the clock to 24-hour format.
Lo and behold, the display colors went all properly warm after 12:24 changed to 0:24!
Now I wonder why the fuck would the code author decide it's a clever idea to take the time as string, slap the locale formatting all over it, and then interpret it as if it was a 24-hour clock — to tell the fucking time.
I don't think it's really Java that's so brain dead. Probably the code is written by the same guy that authored this:
if (myBooleanVariable.toString().length == 4) { .... }
-
It's just God's way of showing His preferred time format.
-
I would suggest that it isn't, as such, Java that causes brain damage. No, I think it's just people demonstrating that a variety of things can cause it, including, but not limited to:
- Eating
- Sleeping
- Walking
- Talking
- Using the Internet
And especially the last one on that list.
-
@wft said in Java does impart some brain damage, after all:
I don't think it's really Java that's so brain dead. Probably the code is written by the same guy that authored this:
if (myBooleanVariable.toString().length == 4) { .... }
I don't do Java, but now I want to test if .Net's parameterless Boolean.ToString() is culture-sensitive... because in French, both
"vrai"
and"faux"
are 4-character long...Edit: I conducted my test, and the conclusion is "no it isn't": Both versions of Boolean.ToString() appear to be invariant:
private static void TestBooleanToString() { CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture; CultureInfo oldUICulture = Thread.CurrentThread.CurrentUICulture; try { CultureInfo french = CultureInfo.GetCultureInfoByIetfLanguageTag("fr-FR"); Thread.CurrentThread.CurrentCulture = french; Thread.CurrentThread.CurrentUICulture = french; Console.WriteLine("Booléen vrai: {0}", true.ToString()); Console.WriteLine("Booléen faux: {0}", false.ToString()); Console.WriteLine("Booléen vrai (FR): {0}", true.ToString(french)); Console.WriteLine("Booléen faux (FR): {0}", false.ToString(french)); } finally { Thread.CurrentThread.CurrentCulture = oldCulture; Thread.CurrentThread.CurrentUICulture = oldUICulture; } }
This outputs:
Booléen vrai: True Booléen faux: False Booléen vrai (FR): True Booléen faux (FR): False
Part of me feels relieved, but another part of me can't help but feel a little disappointed...
-
@Medinoc Is .NET retarded like Java in that it thinks that January is month
0
? Who comes up with this shit?
-
@boomzilla said in Java does impart some brain damage, after all:
Is .NET retarded like Java in that it thinks that January is month 0?
No,
new DateTime(2017, 1, 1)
would return the first of January
-
-
@boomzilla So in Java are the months 0 indexed and the days 1 indexed? Because that would be weird and confusing
-
@boomzilla said in Java does impart some brain damage, after all:
@Medinoc Is .NET retarded like Java in that it thinks that January is month
0
? Who comes up with this shit?You might be thinking of JavaScript, which indexes months from 0 to 11 (Java uses 1 to 12).
-
@Jaloopa Yep. It's retarded. I remember getting into an argument around here at one point with someone trying to defend zero indexing months. They tried to claim that you should just go with zero indexing unless there's a good reason, like people already use the numbers. Right, because no one ever writes a month as a number.
-
@RaceProUK said in Java does impart some brain damage, after all:
You might be thinking of JavaScript, which indexes months from 0 to 11 (Java uses 1 to 12).
I was thinking of Java. Trust me.
-
@boomzilla Looking again, it appears we're both right, as it's 0-11 in some places, and 1-12 in others
-
@RaceProUK said in Java does impart some brain damage, after all:
it appears we're both right
Is this due to the fact that Java's gone through several broken versions of date classes which were all shit in different ways?
-
@Jaloopa Probably. I guess that's why everyone now just says "Use JodaTime".
-
@boomzilla said in Java does impart some brain damage, after all:
@RaceProUK said in Java does impart some brain damage, after all:
You might be thinking of JavaScript, which indexes months from 0 to 11 (Java uses 1 to 12).
I was thinking of Java. Trust me.
This and their stupid attempt of abstracting the calendar in java.util.Calendar (in theory they would have something other than GregorianCalendar, but did they ever implemented one?) are thedailywtf article worthy.
-
@RaceProUK Isn't that the new standard date library as of Java 8? Or if not JodaTime then a shameless ripoff of it
-
@RaceProUK said in Java does impart some brain damage, after all:
@boomzilla Looking again, it appears we're both right, as it's 0-11 in some places, and 1-12 in others
The
Date
andCalendar
classes introduced in Java 1.0 and 1.1 use 0-based months, thejava.time.*
classes introduced in Java 8 (led jointly by the author of Joda-Time) use aMonth
enum with 1-based numeric values.
-
@Jaloopa said in Java does impart some brain damage, after all:
Isn't that the new standard date library as of Java 8?
Maybe? I don't-
@Choonster said in Java does impart some brain damage, after all:
the
java.time.*
classes introduced in Java 8 (led jointly by the author of Joda-Time)Well, there's the answer
-
@RaceProUK said in Java does impart some brain damage, after all:
Maybe? I don't-
What, you don't keep up with all the exciting comings and goings in the world of Java date handling?
-
@Jaloopa said in Java does impart some brain damage, after all:
@RaceProUK said in Java does impart some brain damage, after all:
Maybe? I don't-
What, you don't keep up with all the exciting comings and goings in the world of Java date handling?
I haven't used Java since JDK 1.5.
-
This post is deleted!