java - How to limited String in Android -
in application want show text (date) textview
.
text server , want show text in textview.
text server :
16 dec 2017
but want show such :
2017
how can remove 16 dec
?
try use split()
there 2 signature split() method in java string.
public string split(string regex)
and,
public string split(string regex, int limit)
use split string in java use
.split(" ")
splitsstring
according pattern provided, returning string array.
sample code
string date="16 dec 2017"; string [] dateparts = date.split(" "); string day = dateparts[0]; string month = dateparts[1]; string year = dateparts[2];
Comments
Post a Comment