当前位置: 首页>>代码示例>>Java>>正文


Java Calendar.getInstance方法代码示例

本文整理汇总了Java中java.util.Calendar.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.getInstance方法的具体用法?Java Calendar.getInstance怎么用?Java Calendar.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Calendar的用法示例。


在下文中一共展示了Calendar.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAlarm

import java.util.Calendar; //导入方法依赖的package包/类
public void addAlarm(Date date, int id, String data, int interval, boolean repeating, boolean wakeUpScreen) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);

    SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' h:mm a");

    // intent
    Intent intent = new Intent(c, AlarmReceiver.class);
    intent.putExtra(ALARM_INTENT, data);
    intent.putExtra(Project.SETTINGS_SCREEN_WAKEUP, wakeUpScreen);
    intent.putExtra(Project.NAME, mProject.getName());
    intent.putExtra(Project.FOLDER, mProject.getFolder());
    PendingIntent sender = PendingIntent.getBroadcast(c, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    // Set Alarm
    if (repeating) mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), interval, sender);
    else mAlarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);

    // add to a global alarm thingie
    addTask(new Task(id, mProject, Task.TYPE_ALARM ,cal, interval, repeating, wakeUpScreen));
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:22,代码来源:SchedulerManager.java

示例2: formatDateChat

import java.util.Calendar; //导入方法依赖的package包/类
public static String formatDateChat(long date) {
    try {
        Calendar rightNow = Calendar.getInstance();
        int year = rightNow.get(Calendar.YEAR);

        rightNow.setTimeInMillis(date * 1000);
        int dateYear = rightNow.get(Calendar.YEAR);

        if (year == dateYear) {
            return getInstance().chatDate.format(date * 1000);
        }
        return getInstance().chatFullDate.format(date * 1000);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return "LOC_ERR: formatDateChat";
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:18,代码来源:LocaleController.java

示例3: isNowBetween

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 判断当前时间是否在两个时间段之内
 *
 * @param beginTime 开始时间
 * @param endTime   结束时间
 * @return
 */
public static boolean isNowBetween(String beginTime, String endTime) {
    SimpleDateFormat df = new SimpleDateFormat("HH:mm");
    Date now = null;
    Date begin = null;
    Date end = null;
    try {
        now = df.parse(df.format(new Date()));
        begin = df.parse(beginTime);
        end = df.parse(endTime);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Calendar nowCal = Calendar.getInstance();
    nowCal.setTime(now);

    Calendar beginCal = Calendar.getInstance();
    beginCal.setTime(begin);

    Calendar endCal = Calendar.getInstance();
    endCal.setTime(end);

    if (nowCal.after(beginCal) && nowCal.before(endCal)) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:35,代码来源:TimeUtils.java

示例4: getBeginOfMonthDate

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Ported from blog-posts-per-month.get.js
 */
@SuppressWarnings("deprecation")
private Date getBeginOfMonthDate(Date date)
{
    //TODO These date processing methods are copied almost verbatim from JavaScript to preserve behaviour.
    // However they should be updated to use java.util.Calendar as the current implementation assumes a Gregorian calendar.
    Calendar calendar = Calendar.getInstance();
    calendar.set(date.getYear(), date.getMonth(), 1);
    return calendar.getTime();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:BlogPostsPerMonthGet.java

示例5: getMonthFromDate

import java.util.Calendar; //导入方法依赖的package包/类
public static int getMonthFromDate(Date date) {
	int month = 1;

	if (date != null) {
		Calendar calendar = Calendar.getInstance();

		calendar.setTime(date);
		month = calendar.get(Calendar.MONTH);

		calendar.setTime(date);
		month = calendar.get(Calendar.MONTH);
	}

	return month;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:16,代码来源:DateTimeUtils.java

示例6: ThingDescription

import java.util.Calendar; //导入方法依赖的package包/类
public ThingDescription(String id, String time) {
	
	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	this.id = id;
	this.lifetime = Calendar.getInstance();
	try {
		this.lifetime.setTime(dateFormat.parse(time));
	} catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:13,代码来源:ThingDescription.java

示例7: lengthOfYear

import java.util.Calendar; //导入方法依赖的package包/类
@Override
public int lengthOfYear() {
    Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE);
    jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET);
    jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth());
    return  jcal.getActualMaximum(Calendar.DAY_OF_YEAR);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:JapaneseDate.java

示例8: handleClick

import java.util.Calendar; //导入方法依赖的package包/类
@Override public void handleClick(MonthCellDescriptor cell) {
  Date clickedDate = cell.getDate();

  if(highlightedCells.contains(cell)){
    return;
  }

  Calendar calendar = Calendar.getInstance();
  calendar.setTime(clickedDate);

  int day = calendar.get(DAY_OF_WEEK);
  if(deactivatedDates.contains(day)){
    return;
  }

  if (cellClickInterceptor != null && cellClickInterceptor.onCellClicked(clickedDate)) {
    return;
  }
  if (!betweenDates(clickedDate, minCal, maxCal) || !isDateSelectable(clickedDate)) {
    if (invalidDateListener != null) {
      invalidDateListener.onInvalidDateSelected(clickedDate);
    }
  } else {
    boolean wasSelected = doSelectDate(clickedDate, cell);

    if (dateListener != null) {
      if (wasSelected) {
        dateListener.onDateSelected(clickedDate);
      } else {
        dateListener.onDateUnselected(clickedDate);
      }
    }
  }
}
 
开发者ID:savvisingh,项目名称:DateRangePicker,代码行数:35,代码来源:CalendarPickerView.java

示例9: getLastmondayInt

import java.util.Calendar; //导入方法依赖的package包/类
public static String getLastmondayInt() {

		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date());
		cal.add(Calendar.DAY_OF_MONTH, getMondayPlus() - 7);

		return format(cal.getTime(), "yyyyMMdd");
	}
 
开发者ID:butter-fly,项目名称:belling-spring-rabbitmq,代码行数:9,代码来源:TimeUtils.java

示例10: computNextHourTimeMillis

import java.util.Calendar; //导入方法依赖的package包/类
public static long computNextHourTimeMillis() {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(System.currentTimeMillis());
    cal.add(Calendar.DAY_OF_MONTH, 0);
    cal.add(Calendar.HOUR_OF_DAY, 1);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);

    return cal.getTimeInMillis();
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:12,代码来源:UtilAll.java

示例11: getGmtCalendar

import java.util.Calendar; //导入方法依赖的package包/类
protected Calendar getGmtCalendar() {
    // Worst case we allocate this twice and the other gets GC'd,
    // however prevents deadlock
    if (this.gmtCalendar == null) {
        this.gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    }

    return this.gmtCalendar;
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:10,代码来源:ResultSetImpl.java

示例12: bindView

import java.util.Calendar; //导入方法依赖的package包/类
@Override
protected void bindView(BlotterViewHolder v, Context context, Cursor cursor) {
    long toAccountId = cursor.getLong(BlotterColumns.to_account_id.ordinal());
    String payee = cursor.getString(BlotterColumns.payee.ordinal());
    String note = cursor.getString(BlotterColumns.note.ordinal());
    long locationId = cursor.getLong(BlotterColumns.location_id.ordinal());
    String location = "";
    if (locationId > 0) {
        location = cursor.getString(BlotterColumns.location.ordinal());
    }
    String toAccount = cursor.getString(BlotterColumns.to_account_title.ordinal());
    long fromAmount = cursor.getLong(BlotterColumns.from_amount.ordinal());
    if (toAccountId > 0) {
        v.topView.setText(R.string.transfer);
        if (fromAmount > 0) {
            note = toAccount+" \u00BB";
        } else {
            note = "\u00AB "+toAccount;
        }
        u.setTransferTextColor(v.centerView);
    } else {
        String title = cursor.getString(BlotterColumns.from_account_title.ordinal());
        v.topView.setText(title);
        v.centerView.setTextColor(Color.WHITE);
    }

    long categoryId = cursor.getLong(BlotterColumns.category_id.ordinal());
    String category = "";
    if (categoryId != 0) {
        category = cursor.getString(BlotterColumns.category_title.ordinal());
    }
    String text = generateTransactionTitle(sb, payee, note, location, categoryId, category);
    v.centerView.setText(text);
    sb.setLength(0);

    long currencyId = cursor.getLong(BlotterColumns.from_account_currency_id.ordinal());
    Currency c = CurrencyCache.getCurrency(em, currencyId);
    long originalCurrencyId = cursor.getLong(BlotterColumns.original_currency_id.ordinal());
    if (originalCurrencyId > 0) {
        Currency originalCurrency = CurrencyCache.getCurrency(em, originalCurrencyId);
        long originalAmount = cursor.getLong(BlotterColumns.original_from_amount.ordinal());
        u.setAmountText(sb, v.rightCenterView, originalCurrency, originalAmount, c, fromAmount, true);
    } else {
        u.setAmountText(v.rightCenterView, c, fromAmount, true);
    }
    if (fromAmount > 0) {
        v.iconView.setImageDrawable(icBlotterIncome);
    } else if (fromAmount < 0) {
        v.iconView.setImageDrawable(icBlotterExpense);
    }

    long date = cursor.getLong(BlotterColumns.datetime.ordinal());
    v.bottomView.setText(DateUtils.formatDateTime(context, date,
            DateUtils.FORMAT_SHOW_DATE|DateUtils.FORMAT_SHOW_WEEKDAY|DateUtils.FORMAT_ABBREV_WEEKDAY|DateUtils.FORMAT_SHOW_TIME|DateUtils.FORMAT_ABBREV_MONTH));
    if (date > System.currentTimeMillis()) {
        u.setFutureTextColor(v.bottomView);
    } else {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date);
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        if (dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY) {
            v.bottomView.setTextColor(Color.rgb(224, 112, 112));
        } else {
            v.bottomView.setTextColor(v.topView.getTextColors().getDefaultColor());
        }
    }

    long balance = cursor.getLong(BlotterColumns.from_account_balance.ordinal());
    v.rightView.setText(Utils.amountToString(c, balance, false));
    removeRightViewIfNeeded(v);
    setIndicatorColor(v, cursor);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:73,代码来源:TransactionsListAdapter.java

示例13: getDay

import java.util.Calendar; //导入方法依赖的package包/类
public static Date getDay(String dateString, int dayNum) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(string2date(dateString, "yyyy-MM-dd"));
    cal.add(5, dayNum);
    return cal.getTime();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:7,代码来源:DateUtils.java

示例14: JspCalendar

import java.util.Calendar; //导入方法依赖的package包/类
public JspCalendar() {
    calendar = Calendar.getInstance();
    Date trialTime = new Date();
    calendar.setTime(trialTime);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:6,代码来源:JspCalendar.java

示例15: doInBackground

import java.util.Calendar; //导入方法依赖的package包/类
@Override
protected Calendar doInBackground(Void... unused) {
    return Calendar.getInstance();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:5,代码来源:CardUnmaskPrompt.java


注:本文中的java.util.Calendar.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。