Android Utililty Methods Long to Week Convert

List of utility methods to do Long to Week Convert

Description

The list of methods to do Long to Week Convert are organized into topic(s).

Method

booleanisInNextWeek(long lTime)
is In Next Week
Calendar calToday = Calendar.getInstance();
Calendar calUnknown = Calendar.getInstance();
calToday.setTimeInMillis(System.currentTimeMillis());
calUnknown.setTimeInMillis(lTime);
int nDayOfWeek = calToday.get(Calendar.DAY_OF_WEEK);
if (nDayOfWeek == Calendar.SUNDAY) {
    nDayOfWeek = Calendar.SATURDAY + 1;
nDayOfWeek -= 1;
calToday.add(Calendar.DAY_OF_YEAR, 8 - nDayOfWeek);
if (calUnknown.before(calToday)) {
    return false;
calToday.add(Calendar.DAY_OF_YEAR, 7);
if (calUnknown.after(calToday)) {
    return false;
return true;
booleanisInLastWeek(long lTime)
is In Last Week
Calendar calToday = Calendar.getInstance();
Calendar calUnknown = Calendar.getInstance();
calToday.setTimeInMillis(System.currentTimeMillis());
calUnknown.setTimeInMillis(lTime);
int nDayOfWeek = calToday.get(Calendar.DAY_OF_WEEK);
if (nDayOfWeek == Calendar.SUNDAY) {
    nDayOfWeek = Calendar.SATURDAY + 1;
nDayOfWeek -= 1;
calToday.add(Calendar.DAY_OF_YEAR, -(nDayOfWeek - 1));
if (calUnknown.after(calToday)) {
    return false;
calToday.add(Calendar.DAY_OF_YEAR, -7);
if (calUnknown.before(calToday)) {
    return false;
return true;
booleanisInCurrentWeek(long lTime)
is In Current Week
Calendar calToday = Calendar.getInstance();
Calendar calUnknown = Calendar.getInstance();
calToday.setTimeInMillis(System.currentTimeMillis());
calUnknown.setTimeInMillis(lTime);
int nDayOfWeek = calToday.get(Calendar.DAY_OF_WEEK);
if (nDayOfWeek == Calendar.SUNDAY) {
    nDayOfWeek = Calendar.SATURDAY + 1;
nDayOfWeek -= 1;
calToday.add(Calendar.DAY_OF_YEAR, -(nDayOfWeek - 1));
if (calUnknown.before(calToday)) {
    return false;
calToday.add(Calendar.DAY_OF_YEAR, 7);
if (calUnknown.after(calToday)) {
    return false;
return true;
booleanisBeyondNextWeek(long lTime)
is Beyond Next Week
Calendar calToday = Calendar.getInstance();
Calendar calUnknown = Calendar.getInstance();
calToday.setTimeInMillis(System.currentTimeMillis());
calUnknown.setTimeInMillis(lTime);
int nDayOfWeek = calToday.get(Calendar.DAY_OF_WEEK);
if (nDayOfWeek == Calendar.SUNDAY) {
    nDayOfWeek = Calendar.SATURDAY + 1;
nDayOfWeek -= 1;
calToday.add(Calendar.DAY_OF_YEAR, 8 - nDayOfWeek);
if (calUnknown.before(calToday)) {
    return false;
calToday.add(Calendar.DAY_OF_YEAR, 7);
if (calUnknown.after(calToday)) {
    return true;
return false;
longaddWeek(long dateTimeMillis)
add Week
Calendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(dateTimeMillis);
calendar.add(Calendar.DATE, 7);
return calendar.getTimeInMillis();
longaddWeek(long dateTimeMillis)
add Week
Calendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(dateTimeMillis);
calendar.add(Calendar.DATE, 7);
return calendar.getTimeInMillis();