title: Showing Morning, afternoon, evening, night message based on Time in java
body: <h2>What i am trying to do::</h2>
  
  <p><strong>Show message based on</strong></p>
  
  <ul>
  <li>Good morning  (12am-12pm)</li>
  <li>Good after noon (12pm -4pm)</li>
  <li>Good evening (4pm to 9pm)</li>
  <li>Good night ( 9pm to 6am)</li>
  </ul>
  
  <hr>
  
  <h2>CODE::</h2>
  
  <p>I used 24-hr format to get this logic</p>
  
  <pre><code>private void getTimeFromAndroid() {
          Date dt = new Date();
          int hours = dt.getHours();
          int min = dt.getMinutes();
  
          if(hours&gt;=1 || hours&lt;=12){
              Toast.makeText(this, "Good Morning", Toast.LENGTH_SHORT).show();
          }else if(hours&gt;=12 || hours&lt;=16){
              Toast.makeText(this, "Good Afternoon", Toast.LENGTH_SHORT).show();
          }else if(hours&gt;=16 || hours&lt;=21){
              Toast.makeText(this, "Good Evening", Toast.LENGTH_SHORT).show();
          }else if(hours&gt;=21 || hours&lt;=24){
              Toast.makeText(this, "Good Night", Toast.LENGTH_SHORT).show();
          }
      }
  </code></pre>
  
  <hr>
  
  <h2>Question:</h2>
  
  <ul>
  <li>Is this this best way of doing it, If no which is the best way</li>
  </ul>