String Joiner help needed in Java -
i need in string joiners , want append to_date before string , format after string..
public static stringjoiner inputdatestoquery( list<filesubmtretrlstatus> filesubmtretrlstatus) { stringjoiner joinnames = new stringjoiner(",", "to_date('", "','yyyy-mm-dd hh24:mi:ss')"); // passing comma(,) , square-brackets delimiter (filesubmtretrlstatus status : filesubmtretrlstatus) { joinnames.add(status.getfilesubretdatetime()); } return joinnames;
but out put coming below..
to_date('2017-04-13 11:18:16,2017-04-13 11:17:44,2017-04-13 10:16:07', 'yyyy-mm-dd hh24:mi:ss')
but should below...
to_date('2017-04-13 11:18:16,'yyyy-mm-dd hh24:mi:ss'), to_date('2017-04-13 11:17:44,'yyyy-mm-dd hh24:mi:ss'), to_date('2017-04-13 10:16:07,'yyyy-mm-dd hh24:mi:ss')
stringjoiner produces one output string. example code in documentation is:
the string "[george:sally:fred]" may constructed follows:
stringjoiner sj = new stringjoiner(":", "[", "]"); sj.add("george").add("sally").add("fred"); string desiredstring = sj.tostring();
i.e. takes items add()
, separates them delimiter (in case, comma), , when call tostring()
puts prefix @ beginning of full string, , suffix @ end.
if want use stringjoiner, need separate 1 each entry want output. might want @ formatter or stringbuilder instead.
Comments
Post a Comment