Tabnine Logo
MonthUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
MonthUtils
in
jsc.kit.component.monthview

Best Java code snippets using jsc.kit.component.monthview.MonthUtils (Showing top 6 results out of 315)

origin: JustinRoom/JSCKit

public static List<DayItem> getMonthDays(int year, int month) {
  List<DayItem> dayItems = new ArrayList<>();
  int maxShowCount = 5 * 7;
  addCurrentMonthDays(dayItems, year, month);
  addPreMonthDays(dayItems);
  addNextMonthDays(dayItems, maxShowCount - dayItems.size());
  return dayItems;
}
origin: JustinRoom/JSCKit

/**
 * 获取某一个月的天数
 *
 * @param millis time stamp
 * @return 当月的天数
 */
public static int getMonthDayCount(long millis) {
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(millis);
  return getMonthDayCount(calendar);
}
origin: JustinRoom/JSCKit

/**
 * 添加上个月的最后几天
 *
 * @param dayItems
 */
private static void addPreMonthDays(List<DayItem> dayItems) {
  DayItem firstItem = dayItems.get(0);
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(firstItem.getDate());
  int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
  if (weekDay > Calendar.SUNDAY) {
    calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) - 1);
    DayItem item = new DayItem();
    item.setKey(-1);
    item.setDate(calendar.getTimeInMillis());
    item.setLabel(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
    dayItems.add(0, item);
    addPreMonthDays(dayItems);
  }
}
origin: JustinRoom/JSCKit

private void initMonthView(int year, int month){
  List<DayItem> dayItems = MonthUtils.getMonthDays(year, month);
  for (int i = 0; i < dayItems.size(); i++) {
    boolean enable = new Random().nextBoolean();
    DayItem item = dayItems.get(i);
    switch (item.getKey()){
      case -1://上个月的最后几天
      case 1://下个月的前几天
        item.setBackground(R.drawable.circle_gray_light_shape);
        break;
      case 0://本月的所有天数
        item.setBackground(R.drawable.circle_theme_light_shape);
        break;
    }
    item.setSubLabel(enable ? "可约" : "不可约");
    item.setSubLabelTextColor(enable ? Color.YELLOW : 0xFF666666);
  }
  monthView.setDays(dayItems);
}
origin: JustinRoom/JSCKit

/**
 * 获取某一个月的天数
 *
 * @param date date
 * @return 当月的天数
 */
public static int getMonthDayCount(Date date) {
  Calendar calendar = Calendar.getInstance();
  calendar.setTime(date);
  return getMonthDayCount(calendar);
}
origin: JustinRoom/JSCKit

/**
 * 添加本月所有天数
 *
 * @param dayItems
 */
private static void addCurrentMonthDays(List<DayItem> dayItems, int year, int month) {
  Calendar calendar = Calendar.getInstance();
  calendar.set(Calendar.YEAR, year);
  calendar.set(Calendar.MONTH, month - 1);
  calendar.set(Calendar.HOUR_OF_DAY, 0);
  calendar.set(Calendar.MINUTE, 0);
  calendar.set(Calendar.SECOND, 0);
  calendar.set(Calendar.MILLISECOND, 0);
  int curMonthDayCount = getMonthDayCount(calendar);
  for (int i = 0; i < curMonthDayCount; i++) {
    calendar.set(Calendar.DAY_OF_MONTH, i + 1);
    DayItem item = new DayItem();
    item.setKey(0);
    item.setDate(calendar.getTimeInMillis());
    item.setLabel(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
    dayItems.add(item);
  }
}
jsc.kit.component.monthviewMonthUtils

Javadoc


Email:1006368252@qq.com
QQ:1006368252
https://github.com/JustinRoom/JSCKit

Most used methods

  • addCurrentMonthDays
    添加本月所有天数
  • addNextMonthDays
    添加上个月的最后几天
  • addPreMonthDays
    添加上个月的最后几天
  • getMonthDayCount
    获取某一个月的天数
  • getMonthDays

Popular in Java

  • Finding current android device location
  • startActivity (Activity)
  • getContentResolver (Context)
  • addToBackStack (FragmentTransaction)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Runner (org.openjdk.jmh.runner)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now