Answer the question
In order to leave comments, you need to log in
If (In a certain period of time) how to make such a condition?
I have text that needs to change color at a certain time of the day (For example, from 9:00 to 10:20)
Date yourDateObject = new Date();;
txt = (TextView) findViewById(R.id.textView3);
GregorianCalendar timeToCheck = new GregorianCalendar();
timeToCheck.setTime(yourDateObject);
int hour = timeToCheck.get(GregorianCalendar.HOUR_OF_DAY);
if (hour >= 9 & hour <= 10) {
txt.setTextColor(Color.GREEN);
}
...int min = timeToCheck.get(GregorianCalendar.MINUTE);
if (hour >= 9 & hour <= 10&(min <= 20)) {
txt.setTextColor(Color.GREEN);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question