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(" ") splits string 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

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -