how to split an array of strings in java -
i have array of string type holds columns database holds values of date , time 2014-11-12 16:08:48. have split array retrieve time value, i.e. 16:08:48. how can apply split on array?
thanks in advance.
code through retrieve column values is
class="snippet-code-js lang-js prettyprint-override">public string[] getcharttime() throws sqlexception { list < string > timestr = new arraylist < string > (); string atime[] = null; getconnection(); seek { con = getconnection(); string sql = "exec vcs_gauge @gauge_name=?,@first_rec_time=?,@last_rec_time=?"; dateformat df = new simpledateformat("yyyy-mm-dd hh:mm:ss"); system.out.println("date " + df.format(currentdate)); clstmt = con.preparecall(sql); clstmt.setstring(1, "vs3_bag"); clstmt.setstring(2, "2014-09-01 10:00:00"); clstmt.setstring(3, "2014-09-01 11:00:00"); clstmt.execute(); rs = clstmt.getresultset(); while (rs.next()) { // value of column, , add together list timestr.add(rs.getstring(1)); } } grab (exception e) { system.out.println("\nexception in bean in getdbtable(string code):" + e); } { closeconnection(); } // homecoming list here, let's convert array atime = timestr.toarray(new string[timestr.size()]); homecoming atime; }
now want split timestr array time only, , no date.
you can next code:
// value of column, , add together list timestr.add(rs.getstring(1).split(" ")[1]); java arrays split date-format
No comments:
Post a Comment