简体   繁体   中英

Android TextView with a concatenated value get localized

i am trying to use localisation for an android app , i have a problem with one textView wich its value is concatenated as follow :

 holder.downloadDate.setText(getContext().getString(R.string.downloaded_title) + " " + downloadedItem.getDownloadDate());

and here is getDownloadedDate method :

public String getDownloadDate() {
.....
    return DateUtils.formatDateTime(context, file.lastModified(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NUMERIC_DATE);
}

my problem is that when i change localisation all is fine but the textView value get whole changed (the translated text string + the date itself ) , i want keep the date as it is like for ex : 2019/01/29 and not in a rtl format.

is there a way for that ?

您可以使用Calendar来获取当前的年,月和日,并将它们连接起来,最后使用String.format将数字格式化为两位数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM