How to display a message based on time in android studio : I need to display a message in android studio based on time[enter link description here][1] .**I have enclosed a link here click and view the question in detail** the coding of mine is listed below

    package com.example.lenovo.timegreetfriends;
         import android.support.v7.app.AppCompatActivity;
                import android.os.Bundle;
                import android.view.View;
                import android.widget.Button;
                import android.widget.EditText;
                import android.widget.TextView;
                
                public class MainActivity extends AppCompatActivity implements View.OnClickListener {
                    Button greetButton;
                    @Override
                    protected void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                        setContentView(R.layout.activity_main);
                        greetButton = (Button) findViewById(R.id.greetButton);
                
                        greetButton.setOnClickListener(this);
                    }
                
                    @Override
                    public void onClick(View v) {
                        TextView textMessage = (TextView) findViewById(R.id.textMessage);
                
                        //get a reference to the EditText so that we can read in the value typed by the user
                        EditText editFriendName = (EditText) findViewById(R.id.editFriendName);
                        Date date = new Date();
                        Calendar cal = Calendar.getInstance();
                        cal.setTime(date);
                        int hour = cal.get(Calendar.HOUR_OF_DAY);
                        int min = date.getMinutes();
                        String friendName = editFriendName.getText().toString();
                
                        switch (v.getId()) {
                            case R.id.greetButton:
                                if(hours>=1 || hours<=12) {
                                    Toast.makeText(this, "Good Morning", Toast.LENGTH_SHORT).show();
                                } else if(hours>=12 || hours<=16) {
                                    Toast.makeText(this, "Good Afternoon", Toast.LENGTH_SHORT).show();
                                } else if(hours>=16 || hours<=21) {
                                    Toast.makeText(this, "Good Evening", Toast.LENGTH_SHORT).show();
                                } else if(hours>=21 || hours<=24) {
                                    Toast.makeText(this, "Good Night", Toast.LENGTH_SHORT).show();
                                }
                                textMessage.setText("Good Day "+friendName+"!");
                                break;
                            default:
                                break;

Case:1** If the user types a text(say john) and press a button at 9am.**Output:**Good morning john **Case 2:** If the user types a text(say hari) and press button at 3pm **Output:**Good evening Hari-->
<!--I dont get like that) [1]: https://youtu.be/exkzp3kvfYI
