java.util.Calendar#PM源码实例Demo

下面列出了java.util.Calendar#PM 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void updateAmPmControl() {
    if (is24Hour()) {
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setVisibility(View.GONE);
        } else {
            mAmPmButton.setVisibility(View.GONE);
        }
    } else {
        int index = mIsAm ? Calendar.AM : Calendar.PM;
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setValue(index);
            mAmPmSpinner.setVisibility(View.VISIBLE);
        } else {
            mAmPmButton.setText(mAmPmStrings[index]);
            mAmPmButton.setVisibility(View.VISIBLE);
        }
    }
    mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}
 
private void updateAmPmControl() {
    if (is24Hour()) {
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setVisibility(View.GONE);
        } else {
            mAmPmButton.setVisibility(View.GONE);
        }
    } else {
        int index = mIsAm ? Calendar.AM : Calendar.PM;
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setValue(index);
            mAmPmSpinner.setVisibility(View.VISIBLE);
        } else {
            mAmPmButton.setText(mAmPmStrings[index]);
            mAmPmButton.setVisibility(View.VISIBLE);
        }
    }
    mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}
 
源代码3 项目: ticdesign   文件: TimePickerSpinnerDelegate.java
private void updateAmPmControl() {
    if (is24HourView()) {
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setVisibility(View.GONE);
        } else {
            mAmPmButton.setVisibility(View.GONE);
        }
    } else {
        int index = mIsAm ? Calendar.AM : Calendar.PM;
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setValue(index);
            mAmPmSpinner.setVisibility(View.VISIBLE);
        } else {
            mAmPmButton.setText(mAmPmStrings[index]);
            mAmPmButton.setVisibility(View.VISIBLE);
        }
    }
    mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}
 
源代码4 项目: NewXmPluginSDK   文件: TimePicker.java
private void updateAmPmControl() {
    if (is24HourView()) {
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setVisibility(View.GONE);
        } else {
            mAmPmButton.setVisibility(View.GONE);
        }
    } else {
        int index = mIsAm ? Calendar.AM : Calendar.PM;
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setValue(index);
            mAmPmSpinner.setVisibility(View.VISIBLE);
        } else {
            mAmPmButton.setText(mAmPmStrings[index]);
            mAmPmButton.setVisibility(View.VISIBLE);
        }
    }
    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}
 
源代码5 项目: PhoneProfilesPlus   文件: GlobalGUIRoutines.java
@SuppressLint("SimpleDateFormat")
static String timeDateStringFromTimestamp(Context applicationContext, long timestamp){
    String timeDate;
    String androidDateTime=android.text.format.DateFormat.getDateFormat(applicationContext).format(new Date(timestamp))+" "+
            android.text.format.DateFormat.getTimeFormat(applicationContext).format(new Date(timestamp));
    String javaDateTime = DateFormat.getDateTimeInstance().format(new Date(timestamp));
    String AmPm="";
    if(!Character.isDigit(androidDateTime.charAt(androidDateTime.length()-1))) {
        if(androidDateTime.contains(new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.AM])){
            AmPm=" "+new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.AM];
        }else{
            AmPm=" "+new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.PM];
        }
        androidDateTime=androidDateTime.replace(AmPm, "");
    }
    if(!Character.isDigit(javaDateTime.charAt(javaDateTime.length()-1))){
        javaDateTime=javaDateTime.replace(" "+new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.AM], "");
        javaDateTime=javaDateTime.replace(" "+new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.PM], "");
    }
    javaDateTime=javaDateTime.substring(javaDateTime.length()-3);
    timeDate=androidDateTime.concat(javaDateTime);
    return timeDate.concat(AmPm);
}
 
源代码6 项目: CodenameOne   文件: SimpleDateFormat.java
/**
 * Parse an AM/PM marker. The source marker can be the marker name as
 * defined in DateFormatSymbols, or the first character of the marker name.
 * 
 * @param month as a string.
 * @param offset the offset of original timestamp where marker started, for
 *            error reporting.
 * @return Calendar.AM or Calendar.PM
 * @see DateFormatSymbols
 * @throws ParseException if the source could not be parsed.
 */
int parseAmPmMarker(String source, int ofs) throws ParseException {
	String markers[] = getDateFormatSymbols().getAmPmStrings();
	for (int i = 0; i < markers.length; i++) {
		if (markers[i].equalsIgnoreCase(source)) {
			return i;
		}
	}
	char ch = source.charAt(0);
	if (ch == markers[0].charAt(0)) {
		return Calendar.AM;
	}
	if (ch == markers[1].charAt(0)) {
		return Calendar.PM;
	}
	return throwInvalid("am/pm marker", ofs);
}
 
源代码7 项目: CodenameOne   文件: SimpleDateFormat.java
/**
 * Parse an AM/PM marker. The source marker can be the marker name as
 * defined in DateFormatSymbols, or the first character of the marker name.
 * 
 * @param month as a string.
 * @param offset the offset of original timestamp where marker started, for
 *            error reporting.
 * @return Calendar.AM or Calendar.PM
 * @see DateFormatSymbols
 * @throws ParseException if the source could not be parsed.
 */
int parseAmPmMarker(String source, int ofs) throws ParseException {
	String markers[] = getDateFormatSymbols().getAmPmStrings();
	for (int i = 0; i < markers.length; i++) {
		if (markers[i].equalsIgnoreCase(source)) {
			return i;
		}
	}
	char ch = source.charAt(0);
	if (ch == markers[0].charAt(0)) {
		return Calendar.AM;
	}
	if (ch == markers[1].charAt(0)) {
		return Calendar.PM;
	}
	return throwInvalid("am/pm marker", ofs);
}
 
源代码8 项目: CodenameOne   文件: SimpleDateFormat.java
/**
 * Parse an AM/PM marker. The source marker can be the marker name as
 * defined in DateFormatSymbols, or the first character of the marker name.
 * 
 * @param month as a string.
 * @param offset the offset of original timestamp where marker started, for
 *            error reporting.
 * @return Calendar.AM or Calendar.PM
 * @see DateFormatSymbols
 * @throws ParseException if the source could not be parsed.
 */
int parseAmPmMarker(String source, int ofs) throws ParseException {
	String markers[] = getDateFormatSymbols().getAmPmStrings();
	for (int i = 0; i < markers.length; i++) {
		if (markers[i].equalsIgnoreCase(source)) {
			return i;
		}
	}
	char ch = source.charAt(0);
	if (ch == markers[0].charAt(0)) {
		return Calendar.AM;
	}
	if (ch == markers[1].charAt(0)) {
		return Calendar.PM;
	}
	return throwInvalid("am/pm marker", ofs);
}
 
源代码9 项目: FirefoxReality   文件: BindingAdapters.java
@BindingAdapter("bindDate")
public static void bindDate(@NonNull TextView textView, long timestamp) {
    String androidDateTime = android.text.format.DateFormat.getDateFormat(textView.getContext()).format(new Date(timestamp)) + " " +
            android.text.format.DateFormat.getTimeFormat(textView.getContext()).format(new Date(timestamp));
    String AmPm = "";
    if(!Character.isDigit(androidDateTime.charAt(androidDateTime.length()-1))) {
        if(androidDateTime.contains(new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.AM])){
            AmPm = " " + new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.AM];
        }else{
            AmPm = " " + new SimpleDateFormat().getDateFormatSymbols().getAmPmStrings()[Calendar.PM];
        }
        androidDateTime=androidDateTime.replace(AmPm, "");
    }
    textView.setText(androidDateTime.concat(AmPm));
}
 
源代码10 项目: Weather-Forecast   文件: MainWeatherFrame.java
private void UpdateTimerValue() {
    final Calendar cal = Calendar.getInstance();
    final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    final String timeValue = sdf.format(cal.getTime());
    if (cal.get(Calendar.AM_PM) == Calendar.PM) {
        jLabel20.setText(timeValue + " PM");
    } else {
        jLabel20.setText(timeValue + " AM");
    }
}
 
源代码11 项目: birt   文件: CacheUtil.java
/**
 * To save the current time doing caching or merging
 * 
 * @param folder
 */
public static void saveCurrentTime( String folder ) throws DataException
{
	try
	{
		FileOutputStream fos;

		fos = FileSecurity.createFileOutputStream( new File( folder + PATH_SEP + TIME_DATA ) );

		ObjectOutputStream oos = ObjectSecurity.createObjectOutputStream( fos );

		Calendar calendar = Calendar.getInstance( );

		StringBuffer buffer = new StringBuffer( );

		buffer.append( populate2DigitString( calendar.get( Calendar.YEAR ) ) );
		buffer.append( populate2DigitString( calendar.get( Calendar.MONTH ) + 1 ) );
		buffer.append( populate2DigitString( calendar.get( Calendar.DATE ) ) );
		if ( calendar.get( Calendar.AM_PM ) == Calendar.PM )
			buffer.append( populate2DigitString( calendar.get( Calendar.HOUR ) + 12 ) );
		buffer.append( populate2DigitString( calendar.get( Calendar.MINUTE ) ) );
		buffer.append( populate2DigitString( calendar.get( Calendar.SECOND ) ) );

		oos.writeObject( buffer.toString( ) );

		fos.close( );
		oos.close( );
	}
	catch ( IOException e )
	{
		throw new DataException( e.getLocalizedMessage( ) );
	}

}
 
源代码12 项目: utexas-utilities   文件: ScheduleClassAdapter.java
public void updateTime() {
    Calendar cal = Calendar.getInstance();
    int day = cal.get(Calendar.DAY_OF_WEEK) - 2;
    String time = cal.get(Calendar.HOUR) + (cal.get(Calendar.MINUTE) >= 30 ? ":30" : ":00")
            + (cal.get(Calendar.AM_PM) == Calendar.PM ? "pm" : "");

    if (day < 5 && day >= 0 && cal.get(Calendar.HOUR_OF_DAY) <= 22
            && cal.get(Calendar.HOUR_OF_DAY) >= 6) {
        currentTimePos = day + 5 * timeToPos(time);
        currMinutes = cal.get(Calendar.MINUTE) % 30;
    }
}