This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to convert string into string array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to convert string into string array" Watch "how to convert string into string array" New topic
Author

how to convert string into string array

Baktha Elumalai
Greenhorn

Joined: Mar 13, 2010
Posts: 28
input

row1: "2010-04-21 11:01:35",
row2: "2010-04-22 11:01:58",
row3: "2010-04-23 11:02:21",
row4: "2010-04-24 11:02:42",
row4: "2010-04-24 11:03:28",
row5: "2010-04-25 11:03:51"

i get the data like this
i need to get the hh, mm and ss seperate and compare each row by row the hh mm ss is same or not


i need temp = gpstime[k].split(" ");

please help me


Regards
Bakthavachalam E
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Why don't you put the Strings into a SimpleDateFormat or similar class, get an instance from that, and separate the time from that? What is wrong with the split() call you are using?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(Consider posting only the code necessary to deal w/ the question--the loop and JDBC isn't really relevant :)
Gokul Nanthakumar
Ranch Hand

Joined: May 11, 2010
Posts: 56
As the String length and format is known you can simply use String.substring() for find the HH MM values
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
David Newton wrote: . . . the JDBC isn't really relevant . . .
And it's even harder to read as one line; I had to put new lines in for you. Please avoid such long lines inside code tags.
sai prashanth
Greenhorn

Joined: May 04, 2010
Posts: 18

row1: "2010-04-21 11:01:35",
row2: "2010-04-22 11:01:58",
row3: "2010-04-23 11:02:21",


If the input you have provided is right, then I think you also need to take in to account the date part too. How about converting the date/time in to milliseconds and then comparing it?

Baktha Elumalai
Greenhorn

Joined: Mar 13, 2010
Posts: 28
Hi i used same way



ouput



the above output how to compare the hh, mm and ss row by row
if any idea please help me
Gokul Nanthakumar
Ranch Hand

Joined: May 11, 2010
Posts: 56
if you want to unique data put the result into Set and get the unique result or just want to compare and find the given time is already there are not, put them into hashset or hashmap(according to your requirement) and compare it is already available or not.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Campbell Ritchie wrote:Why don't you put the Strings into a SimpleDateFormat or similar class, get an instance from that, and separate the time from that? What is wrong with the split() call you are using?


To those interested - this topic has been running for over 5 days and it is still not clear what the OP is trying to do.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Wow, that's borderline epic.
Baktha Elumalai
Greenhorn

Joined: Mar 13, 2010
Posts: 28
Gokul Nanthakumar wrote:if you want to unique data put the result into Set and get the unique result or just want to compare and find the given time is already there are not, put them into hashset or hashmap(according to your requirement) and compare it is already available or not.

please send any eaxmple
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Example of what, how to put data into a set?
Baktha Elumalai
Greenhorn

Joined: Mar 13, 2010
Posts: 28
yes
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Is the Java™ Tutorials section about collections any use to you?
 
wood burning stoves
 
subject: how to convert string into string array
 
Similar Threads
how do i compare row by row
how to compare row by row
how do get particular date of total time
MyFaces Tomahawk t:columns tag - basic example needed
Prevent selection of certain JTable cells