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


Java Time.set方法代码示例

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


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

示例1: formatTime

import android.text.format.Time; //导入方法依赖的package包/类
public static String formatTime(Context context, long when) {
	// TODO: DateUtils should make this easier
	Time then = new Time();
	then.set(when);
	Time now = new Time();
	now.setToNow();

	int flags = DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL;

	if (then.year != now.year) {
		flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
	} else if (then.yearDay != now.yearDay) {
		flags |= DateUtils.FORMAT_SHOW_DATE;
	} else {
		flags |= DateUtils.FORMAT_SHOW_TIME;
	}

	return DateUtils.formatDateTime(context, when, flags);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:20,代码来源:Utils.java

示例2: a

import android.text.format.Time; //导入方法依赖的package包/类
public String a(int i, Thread thread, long j, String str, String str2, Throwable th) {
    long j2 = j % 1000;
    Time time = new Time();
    time.set(j);
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(a(i)).append(LetvUtils.CHARACTER_BACKSLASH).append(time.format("%Y-%m-%d %H:%M:%S")).append('.');
    if (j2 < 10) {
        stringBuilder.append("00");
    } else if (j2 < 100) {
        stringBuilder.append('0');
    }
    stringBuilder.append(j2).append(' ').append('[');
    if (thread == null) {
        stringBuilder.append("N/A");
    } else {
        stringBuilder.append(thread.getName());
    }
    stringBuilder.append(']').append('[').append(str).append(']').append(' ').append(str2).append('\n');
    if (th != null) {
        stringBuilder.append("* Exception : \n").append(Log.getStackTraceString(th)).append('\n');
    }
    return stringBuilder.toString();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:24,代码来源:h.java

示例3: updateTime

import android.text.format.Time; //导入方法依赖的package包/类
private void updateTime() {
	// TODO KIO Is this really necessary to creat a calendar?
	// Calendar calendar = Calendar.getInstance();
	// calendar.setTime(mTest.getDate());

	Log.d(TAG_KIO, "Inside updateTime() mDate time is: "
			+ mTest.getDate().getTime());
	Log.d(TAG_KIO, "Inside updateTime() mDate is: " + mTest.getDate());

	Time time = new Time();
	time.set(mTest.getDate().getTime());

	String timeFormat = time.format("%I:%M");
	Log.d(TAG_KIO, "timeFormat is: " + timeFormat);
	mTimeButton.setText(timeFormat);
}
 
开发者ID:publiclab,项目名称:SmART-Form,代码行数:17,代码来源:TestFragment.java

示例4: formatTime

import android.text.format.Time; //导入方法依赖的package包/类
static public String formatTime(int ms) {
    String res;
    if (ms <= 0) {
        res = EMPTY_STRING;
    } else {
        Time t = new Time();
        t.set(ms);
        t.switchTimezone(Time.TIMEZONE_UTC);
        if (ms >= 3600000) {
            res = t.format(TIME_HOUR);
        } else if (ms < 60000)
            res = t.format(TIME_SECOND);
        else
            res = t.format(TIME_MINUTE);

        if (res.charAt(0) == '0') {
            res = res.substring(1);
        }
    }
    return res;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:22,代码来源:Browser.java

示例5: a

import android.text.format.Time; //导入方法依赖的package包/类
public String a(int i, Thread thread, long j, String str, String str2, Throwable th) {
    long j2 = j % 1000;
    Time time = new Time();
    time.set(j);
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(a(i)).append('/').append(time.format("%Y-%m-%d %H:%M:%S")).append('.');
    if (j2 < 10) {
        stringBuilder.append("00");
    } else if (j2 < 100) {
        stringBuilder.append('0');
    }
    stringBuilder.append(j2).append(' ').append('[');
    if (thread == null) {
        stringBuilder.append("N/A");
    } else {
        stringBuilder.append(thread.getName());
    }
    stringBuilder.append(']').append('[').append(str).append(']').append(' ').append(str2)
            .append('\n');
    if (th != null) {
        stringBuilder.append("* Exception : \n").append(Log.getStackTraceString(th)).append
                ('\n');
    }
    return stringBuilder.toString();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:h.java

示例6: parse

import android.text.format.Time; //导入方法依赖的package包/类
public static long parse(String timeString)
        throws IllegalArgumentException {

    int date = 1;
    int month = Calendar.JANUARY;
    int year = 1970;
    TimeOfDay timeOfDay;

    Matcher rfcMatcher = HTTP_DATE_RFC_PATTERN.matcher(timeString);
    if (rfcMatcher.find()) {
        date = getDate(rfcMatcher.group(1));
        month = getMonth(rfcMatcher.group(2));
        year = getYear(rfcMatcher.group(3));
        timeOfDay = getTime(rfcMatcher.group(4));
    } else {
        Matcher ansicMatcher = HTTP_DATE_ANSIC_PATTERN.matcher(timeString);
        if (ansicMatcher.find()) {
            month = getMonth(ansicMatcher.group(1));
            date = getDate(ansicMatcher.group(2));
            timeOfDay = getTime(ansicMatcher.group(3));
            year = getYear(ansicMatcher.group(4));
        } else {
            throw new IllegalArgumentException();
        }
    }

    // FIXME: Y2038 BUG!
    if (year >= 2038) {
        year = 2038;
        month = Calendar.JANUARY;
        date = 1;
    }

    Time time = new Time(Time.TIMEZONE_UTC);
    time.set(timeOfDay.second, timeOfDay.minute, timeOfDay.hour, date,
            month, year);
    return time.toMillis(false /* use isDst */);
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:39,代码来源:HttpDateTime.java

示例7: formatTime

import android.text.format.Time; //导入方法依赖的package包/类
public String formatTime(long ms) {
	String res;
	if (ms == 0) {
		res = "";
	} else {
		Time t = new Time();
		t.set(ms);
		t.switchTimezone(Time.TIMEZONE_UTC);
		if (ms >= 3600000) {
			res = t.format("%kh%M'");
		} else if (ms < 60000)
			res = t.format("%S''");
		else
			res = t.format("%M'%S''");

		if (res.charAt(0) == '0') {
			res = res.substring(1);
		}
	}
	return res;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:22,代码来源:ArtworkFactory.java

示例8: normalizeDate

import android.text.format.Time; //导入方法依赖的package包/类
public static long normalizeDate(long startDate) {
    // normalize the start date to the beginning of the (UTC) day
    Time time = new Time();
    time.set(startDate);
    int julianDay = Time.getJulianDay(startDate, time.gmtoff);
    return time.setJulianDay(julianDay);
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:8,代码来源:WeatherContract.java

示例9: a

import android.text.format.Time; //导入方法依赖的package包/类
public static long a(String str) {
    int c;
    int d;
    a e;
    int i;
    int i2 = 1;
    Matcher matcher = a.matcher(str);
    int b;
    if (matcher.find()) {
        b = b(matcher.group(1));
        c = c(matcher.group(2));
        d = d(matcher.group(3));
        e = e(matcher.group(4));
        i = b;
    } else {
        Matcher matcher2 = b.matcher(str);
        if (matcher2.find()) {
            c = c(matcher2.group(1));
            b = b(matcher2.group(2));
            a e2 = e(matcher2.group(3));
            d = d(matcher2.group(4));
            e = e2;
            i = b;
        } else {
            throw new IllegalArgumentException();
        }
    }
    if (d >= 2038) {
        d = 2038;
        c = 0;
    } else {
        i2 = i;
    }
    Time time = new Time("UTC");
    time.set(e.c, e.b, e.a, i2, c, d);
    return time.toMillis(false);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:38,代码来源:k.java

示例10: run

import android.text.format.Time; //导入方法依赖的package包/类
@SuppressLint("SimpleDateFormat")
@Override
public void run() {
    // 实时发送一个更新的广播
    final String pref_key = "appwidget_news_refresh_time";
    final long updatePeriod = 10 * 60 * 1000;
    final long lastRefreshTime = Utils.getLong(this, pref_key, 0);
    final long now = System.currentTimeMillis();
    if (now - lastRefreshTime >= updatePeriod) {
        // 10分钟内不执行重复的后台更新请求
        Utils.putLong(this, pref_key, now);

        Intent refreshNowIntent = new Intent(this, NewsAppWidgetProvider.class);
        refreshNowIntent.setAction(NewsAppWidgetProvider.ACTION_REFRESH_AUTO);
        sendBroadcast(refreshNowIntent);
    }

    Intent autoRefreshIntent = new Intent(this, NewsAppWidgetProvider.class);
    autoRefreshIntent.setAction(NewsAppWidgetProvider.ACTION_REFRESH_AUTO);
    PendingIntent pending = PendingIntent.getBroadcast(NewsWidgetService.this, 0, autoRefreshIntent, 0);

    // 1*60秒更新一次
    final long updateTime = 1 * 60 * 1000;
    Time time = new Time();
    long nowMillis = System.currentTimeMillis();
    time.set(nowMillis + updateTime);
    long updateTimes = time.toMillis(true);

    // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    // Log.d(TAG, "request next update at " + updateTimes);
    // Log.d(TAG, "refresh time: " + sdf.format(new Date()));

    AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarm.set(AlarmManager.RTC_WAKEUP, updateTimes, pending);
    stopSelf();
}
 
开发者ID:benniaobuguai,项目名称:opencdk-appwidget,代码行数:37,代码来源:NewsWidgetService.java

示例11: getStringtoDate

import android.text.format.Time; //导入方法依赖的package包/类
private JSONObject getStringtoDate(JSONArray options)throws GlobalizationError{
    JSONObject obj = new JSONObject();
    Date date;
    try{
        //get format pattern from android device (Will only have device specific formatting for short form of date) or options supplied
        DateFormat fmt = new SimpleDateFormat(getDatePattern(options).getString("pattern"));

        //attempt parsing string based on user preferences
        date = fmt.parse(options.getJSONObject(0).get(DATESTRING).toString());

        //set Android Time object
        Time time = new Time();
        time.set(date.getTime());

        //return properties;
        obj.put("year", time.year);
        obj.put("month", time.month);
        obj.put("day", time.monthDay);
        obj.put("hour", time.hour);
        obj.put("minute", time.minute);
        obj.put("second", time.second);
        obj.put("millisecond", Long.valueOf(0));
        return obj;
    }catch(Exception ge){
        throw new GlobalizationError(GlobalizationError.PARSING_ERROR);
    }
}
 
开发者ID:chrisuehlinger,项目名称:smart-mirror-app,代码行数:28,代码来源:Globalization.java

示例12: updateFlowLayout

import android.text.format.Time; //导入方法依赖的package包/类
void updateFlowLayout(RecurrenceOption recurrenceOption) {
    // Currently selected recurrence option
    int viewIdToSelect;

    switch (recurrenceOption) {
        case DOES_NOT_REPEAT:
            viewIdToSelect = R.id.tvDoesNotRepeat;
            break;
        case DAILY:
            viewIdToSelect = R.id.tvDaily;
            break;
        case WEEKLY:
            viewIdToSelect = R.id.tvWeekly;
            break;
        case MONTHLY:
            viewIdToSelect = R.id.tvMonthly;
            break;
        case YEARLY:
            viewIdToSelect = R.id.tvYearly;
            break;
        case CUSTOM:
            viewIdToSelect = R.id.tvChosenCustomOption;
            break;
        default:
            viewIdToSelect = R.id.tvDoesNotRepeat;
    }

    for (TextView tv : mRepeatOptionTextViews) {
        tv.setOnClickListener(this);

        // If we have a non-empty recurrence rule,
        // display it for easy re-selection
        if (tv.getId() == R.id.tvChosenCustomOption) {
            if (!TextUtils.isEmpty(mRecurrenceRule)) {
                EventRecurrence eventRecurrence = new EventRecurrence();
                eventRecurrence.parse(mRecurrenceRule);
                Time startDate = new Time(TimeZone.getDefault().getID());
                startDate.set(mCurrentlyChosenTime);
                eventRecurrence.setStartDate(startDate);

                tv.setVisibility(View.VISIBLE);

                tv.setText(EventRecurrenceFormatter.getRepeatString(
                        getContext(), getContext().getResources(),
                        eventRecurrence, true));
            } else { // hide this TextView since 'mRecurrenceRule' is not available
                tv.setVisibility(View.GONE);
                continue;
            }
        }

        // Selected option
        if (tv.getId() == viewIdToSelect) {
            // Set checkmark drawable & drawable-padding
            tv.setCompoundDrawablesWithIntrinsicBounds(null, null,
                    mCheckmarkDrawable, null);
            tv.setCompoundDrawablePadding(mSelectedOptionDrawablePadding);
            tv.setTextColor(mSelectedStateTextColor);

            continue;
        }

        // Unselected options
        tv.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        tv.setTextColor(mUnselectedStateTextColor);
    }
}
 
开发者ID:andela-kogunde,项目名称:CheckSmarter,代码行数:68,代码来源:SublimeRecurrencePicker.java


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