Created
September 14, 2012 04:57
-
-
Save billynyh/3719885 to your computer and use it in GitHub Desktop.
my android text helper : strike text, underline, decimal format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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