Skip to content

Instantly share code, notes, and snippets.

@vuhung3990
Created November 6, 2014 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vuhung3990/b0bb31369d2931e06da4 to your computer and use it in GitHub Desktop.
Save vuhung3990/b0bb31369d2931e06da4 to your computer and use it in GitHub Desktop.
// WEEK
Calendar first = Calendar.getInstance();
first.add(Calendar.DAY_OF_WEEK, first.getFirstDayOfWeek() - first.get(Calendar.DAY_OF_WEEK));
int startWeek = first.get(Calendar.DATE);
int endWeek = startWeek + 6;
// MONTH
// start = 1
Calendar date = Calendar.getInstance();
date.set(Calendar.DAY_OF_MONTH, first.getActualMaximum(Calendar.DAY_OF_MONTH));
int endMonth = first.get(Calendar.DAY_OF_MONTH);
// format 2 digit
sample: String.format("%02d", first.get(Calendar.DAY_OF_MONTH))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment