Tuesday, 15 May 2012

Java convert long day name to short name -


I found a day's name in the form of a string like Monday , Tuesday or any weekday name. But I want to display it as a short day format. Like Mon , lawsuit and so on. Is there any reasonable way to do this? Remember the day name is string not date or calendar.

a map & lt; & Gt; or @ zorian string. Substring () are the best ways, another less efficient yet rare method:

  SimpleDateFormat sdf = New SimpleDateFormat (" EEE "); SimpleDateFormat sdf2 = New SimpleDateform ("E"); System.out.println ("> gt;>" + sdf2.format (sdf.parse ("Monday")));  

No comments:

Post a Comment