Get this Month Ending date by timezone - Android java.util

Android examples for java.util:Timezone

Description

Get this Month Ending date by timezone

Demo Code

import java.util.Calendar;
import java.util.TimeZone;

public class Main{
  private static final TimeZone TIME_ZONE = TimeZone.getTimeZone("Asia/Tokyo");

  public static Calendar firstDate() {
    Calendar cal = Calendar.getInstance(TIME_ZONE);
    cal.set(Calendar.DATE, 1);/*from ww w  .j  a v a 2s  . co m*/
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal;
  }

    public static long thisMonthEnd() {
        Calendar cal = firstDate();
        cal.add(Calendar.MONTH, 1);
        cal.add(Calendar.MILLISECOND, -1);
        return cal.getTimeInMillis();
    }

}

Related Tutorials