當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleDateFormat.setCalendar方法代碼示例

本文整理匯總了Java中java.text.SimpleDateFormat.setCalendar方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleDateFormat.setCalendar方法的具體用法?Java SimpleDateFormat.setCalendar怎麽用?Java SimpleDateFormat.setCalendar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.text.SimpleDateFormat的用法示例。


在下文中一共展示了SimpleDateFormat.setCalendar方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Test4061476

import java.text.SimpleDateFormat; //導入方法依賴的package包/類
public void Test4061476() {
    SimpleDateFormat fmt = new SimpleDateFormat("ddMMMyy", Locale.UK);
    Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"),
            Locale.UK);
    fmt.setCalendar(cal);
    try {
        Date date = fmt.parse("29MAY97");
        cal.setTime(date);
    } catch (Exception e) {
    }
    cal.set(HOUR_OF_DAY, 13);
    logln("Hour: " + cal.get(HOUR_OF_DAY));
    cal.add(HOUR_OF_DAY, 6);
    logln("Hour: " + cal.get(HOUR_OF_DAY));
    if (cal.get(HOUR_OF_DAY) != 19) {
        errln("Fail: Want 19 Got " + cal.get(HOUR_OF_DAY));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:CalendarRegression.java

示例2: date

import java.text.SimpleDateFormat; //導入方法依賴的package包/類
public static String date() {
       Calendar cal = Calendar.getInstance();
       int year = cal.get(Calendar.YEAR);
       SimpleDateFormat dateFormat = new SimpleDateFormat("MMMMMMMMM dd, yyyy");
       dateFormat.setCalendar(cal);
	return dateFormat.format(cal.getTime());
}
 
開發者ID:Suhas010,項目名稱:Artificial-Intelligent-chat-bot-,代碼行數:8,代碼來源:CalendarUtils.java

示例3: onReceive

import java.text.SimpleDateFormat; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    mCalendar.setTimeZone(TimeZone.getDefault());
    dayOfWeekFormat = new SimpleDateFormat("EEEE", Locale.getDefault());
    dayOfWeekFormat.setCalendar(mCalendar);
    dateFormat = DateFormat.getDateFormat(MyWatchFace.this);
    dateFormat.setCalendar(mCalendar);
    invalidate();
}
 
開發者ID:changja88,項目名稱:Android_Sunshine_Watch,代碼行數:10,代碼來源:MyWatchFace.java

示例4: onCreate

import java.text.SimpleDateFormat; //導入方法依賴的package包/類
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFace.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());
    Resources resources = MyWatchFace.this.getResources();

    googleApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Wearable.API)
            .build();
    googleApiClient.connect();

    // Colors
    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(resources.getColor(R.color.orange));
    hourPaint = createTextPaint(resources.getColor(R.color.white));
    minutePaint = createTextPaint(resources.getColor(R.color.white));
    colonPaint = createTextPaint(resources.getColor(R.color.white));
    highPaint = createTextPaint(resources.getColor(R.color.white));
    lowPaint = createTextPaint(resources.getColor(R.color.white));

    // Initialize member variables
    mCalendar = Calendar.getInstance();
    date = new Date();
    dayOfWeekFormat = new SimpleDateFormat("EEEE", Locale.getDefault());
    dayOfWeekFormat.setCalendar(mCalendar);
    dateFormat = DateFormat.getDateFormat(MyWatchFace.this);
    dateFormat.setCalendar(mCalendar);
}
 
開發者ID:changja88,項目名稱:Android_Sunshine_Watch,代碼行數:36,代碼來源:MyWatchFace.java

示例5: formatTime

import java.text.SimpleDateFormat; //導入方法依賴的package包/類
public static String formatTime(String formatString, long msSinceEpoch) {
       SimpleDateFormat dateFormat = new SimpleDateFormat(formatString);
	Calendar cal = Calendar.getInstance();
	dateFormat.setCalendar(cal);
	return dateFormat.format(new Date(msSinceEpoch));
}
 
開發者ID:Suhas010,項目名稱:Artificial-Intelligent-chat-bot-,代碼行數:7,代碼來源:CalendarUtils.java


注:本文中的java.text.SimpleDateFormat.setCalendar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。