Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How the get the current day name using particular date in android?

Tags:

I have date string 18-2-2012 , from this how to get the current day name i.e., today is "saturday" like this. for tomorrow's date 19-2-2012 and the day name is "sunday".

like image 796
VaaS Avatar asked Feb 18 '12 12:02

VaaS


People also ask

How can I get current date in Android?

getInstance(). getTime(); System. out. println("Current time => " + c); SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy"); String formattedDate = df.

How do I display the day of the week in Android?

SimpleDateFormat sdf_ = new SimpleDateFormat("EEEE"); Date date = new Date(); String dayName = sdf_. format(date); timeUpdate. setText("" + dayName + " " + currentDate + "");

How do you get the current day in Kotlin?

This example demonstrates how to get the current time and date in an Android app Kotlin. Step 1 − Create a new project in Android Studio, go to File ⇉ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How can I get tomorrow date in Android?

get(Calendar. DAY_OF_MONTH) + 1; will it display tomorrow's date. or just add one to today's date? For example, if today is January 31.


2 Answers

Use java date formats.

SimpleDateFormat inFormat = new SimpleDateFormat("dd-MM-yyyy"); Date date = inFormat.parse(input); SimpleDateFormat outFormat = new SimpleDateFormat("EEEE"); String goal = outFormat.format(date);  
like image 90
Boris Strandjev Avatar answered Oct 12 '22 02:10

Boris Strandjev


You can use Calendar

            Calendar calendar = Calendar.getInstance();              calendar.setTime(date_your_want_to_know);              String[] days = new String[] { "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY" }              String day = days[calendar.get(Calendar.DAY_OF_WEEK)]; 
like image 28
Vivek Khandelwal Avatar answered Oct 12 '22 01:10

Vivek Khandelwal