當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。