java - Remove the hour,minute and seconds from date gotten from server as JSON -


i getting json data server includes dates too. shows date 2017-07-20 00:00:00 want see date this:2017-07-20, , checked previous questions issue of them based on date in android side. , problem date json , because of don't know how remove time it.

did try simple parse string this?

string date_string = "2017-07-20 00:00:00"; string[] parsed = date_string.split(" "); string your_wanted_string = parsed[0]; system.out.println(your_wanted_string); 

edit

  1. you have convert string date here : https://stackoverflow.com/a/4216767/1979882
  2. convert date milliseconds. or use calendar class.
  3. calculate difference between values.

an example:

http://www.mkyong.com/java/how-do-get-time-in-milliseconds-in-java/

public class timemilisecond {   public static void main(string[] argv) throws parseexception {      simpledateformat sdf = new simpledateformat("dd-m-yyyy hh:mm:ss");     string dateinstring = "22-01-2015 10:20:56";     date date = sdf.parse(dateinstring);      system.out.println(dateinstring);     system.out.println("date - time in milliseconds : " + date.gettime());      calendar calendar = calendar.getinstance();     calendar.settime(date);     system.out.println("calender - time in milliseconds : " + calendar.gettimeinmillis());    } } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -