Android examples for java.util:Time
get Greeting based on time
//package com.java2s; import android.text.format.Time; public class Main { public static String getGreeting() { int hour = getHour(); if (hour > 0 && hour < 12) { return "Good morning"; } else if (hour > 12 && hour < 18) { return "Good afternoon"; } else {//from w ww . j av a2 s. c om return "Good evening"; } } private static int getHour() { Time now = new Time(Time.getCurrentTimezone()); now.setToNow(); return now.hour; } }