Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

how to convert string into string array

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 65762
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Consider posting only the code necessary to deal w/ the question--the loop and JDBC isn't really relevant :)
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the String length and format is known you can simply use String.substring() for find the HH MM values
 
Campbell Ritchie
Marshal
Posts: 65762
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that's borderline epic.
 
Baktha Elumalai
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example of what, how to put data into a set?
 
Baktha Elumalai
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Campbell Ritchie
Marshal
Posts: 65762
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the Java™ Tutorials section about collections any use to you?
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!