• Welcome to Valhalla Legends Archive.
 

subString

Started by Falcon[anti-yL], October 14, 2004, 08:39 PM

Previous topic - Next topic

Falcon[anti-yL]

I'm writing a program that tells you what day you were born on. I want to input the year in 4 digits, then check to see if its before 1900. If its not, I want to take the last 2 digits out of the 4 digits. I know there was a subString for Strings but is there a way to do it for Integers?

The-FooL


Integer.toString(var).substring(...etc..)

iago

There's actually a built-in class for converting a date to a java.util.Date.  But I can't remember what it is.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MyndFyre

Quote from: iago on October 15, 2004, 01:02 PM
There's actually a built-in class for converting a date to a java.util.Date.  But I can't remember what it is.
DateFormat.parse(String)
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

CrAzY

I don't think this is the easiest way to do it but it should work if done correctly.

Make your substring, to get the last 2 digits.  now with that substring, use the toCharArray() method.  Then basically make a converter if char=='1' { int = 1

I didn't make that TOO clear at all, but if you get what I'm saying, you should get it.

Please post an easier way if you know one somebody.
CrAzY

Falcon[anti-yL]

I got mine to work, I just basically stored the input 2 times, one as a string and the other as a string.
I don't know the toCharArray() method yet, I'm still learning.