How to convert week name to week number in java/android

/**
 * @param weekDayNumber Week Number starts with 1. For <b>Sunday</b> it is <b>1</b> and for <b>Saturday</b> it is <b>7</b>.
 * @return
 */
 public static String getWeekDayFullName(int weekDayNumber)
 {
 String weekName = "";

 if(weekDayNumber>0 && weekDayNumber<8)
 {
 try {
 Calendar calendar = Calendar.getInstance();
 calendar.set(Calendar.DAY_OF_WEEK, weekDayNumber);

 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEEE");
 simpleDateFormat.setCalendar(calendar);
 weekName = simpleDateFormat.format(calendar.getTime());
 } catch (Exception e)
 {
 if(e!=null)
 e.printStackTrace();
 }
 }
 return weekName;
 }
Advertisements

Tags: , , , , , , ,

About krishjlk

http://www.facebook.com/krishna.kanth.121

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: