Skip to content

Instantly share code, notes, and snippets.

@billynyh
Created September 14, 2012 04:57
Show Gist options
  • Save billynyh/3719885 to your computer and use it in GitHub Desktop.
Save billynyh/3719885 to your computer and use it in GitHub Desktop.
my android text helper : strike text, underline, decimal format
public class TextHelper {
public static SpannableString strikeText(String text){
if (text==null)text = "";
SpannableString str = new SpannableString(text);
str.setSpan(new StrikethroughSpan(), 0, str.length(), Spanned.SPAN_PARAGRAPH);
return str;
}
public static SpannableString underlineText(String text){
if (text==null)text = "";
SpannableString str = new SpannableString(text);
str.setSpan(new UnderlineSpan(), 0, str.length(), Spanned.SPAN_PARAGRAPH);
return str;
}
public static String decimalFormat(float v){
return new DecimalFormat("@@##").format(v);
}
public static String getCurrentTimeString() {
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//dd/MM/yyyy
Date now = new Date();
String strDate = sdfDate.format(now);
return strDate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment