List of usage examples for java.util Calendar AM
int AM
To view the source code for java.util Calendar AM.
Click Source Link
From source file:MailDateFormatter.java
private static String getAMPM(Calendar cal) { return (cal.get(Calendar.AM_PM) == Calendar.AM) ? "a" : "p"; }
From source file:com.licubeclub.zionhs.MainActivity.java
void networkTask() { SRL.setRefreshing(true);//from ww w. j av a 2s . com final Handler handler = new Handler() { @Override public void handleMessage(Message msg) { } }; final Handler mHandler = new Handler(); new Thread() { public void run() { mHandler.post(new Runnable() { public void run() { // SRL.setRefreshing(true); } }); try { lunchstring = MealLoadHelper.getMeal("goe.go.kr", "J100000659", "4", "04", "2"); //Get Lunch Menu Date dinnerstring = MealLoadHelper.getMeal("goe.go.kr", "J100000659", "4", "04", "3"); //Get Dinner Menu Date } catch (Exception e) { } try { int skipcount = 0; boolean skipped = false; schedulearray = new ArrayList<String>(); dayarray = new ArrayList<String>(); // ? ?? ? ?? Document doc = Jsoup.connect(URL).get(); Elements rawdaydata = doc.select(".listDay"); //Get contents from the class,"listDay" for (Element el : rawdaydata) { String daydata = el.text(); if (daydata.equals("") | daydata == null) { if (skipped) { } else { skipcount++; } } else { dayarray.add(daydata); // add value to ArrayList skipped = true; } } Log.d("Schedule", "Parsed Day Array" + dayarray); Elements rawscheduledata = doc.select(".listData"); //Get contents from tags,"a" which are in the class,"ellipsis" for (Element el : rawscheduledata) { String scheduledata = el.text(); if (skipcount > 0) { skipcount--; } else { schedulearray.add(scheduledata); // add value to ArrayList } } Log.d("Schedule", "Parsed Schedule Array" + schedulearray); // SRL.setRefreshing(false); } catch (IOException e) { e.printStackTrace(); // SRL.setRefreshing(false); } try { titlearray_np = new ArrayList<String>(); Document doc = Jsoup.connect( "http://www.zion.hs.kr/main.php?menugrp=110100&master=bbs&act=list&master_sid=59") .get(); Elements rawdata = doc.select(".listbody a"); //Get contents from tags,"a" which are in the class,"listbody" String titlestring = rawdata.toString(); Log.i("Notices", "Parsed Strings" + titlestring); for (Element el : rawdata) { String titledata = el.attr("title"); titlearray_np.add(titledata); // add value to ArrayList } Log.i("Notices", "Parsed Array Strings" + titlearray_np); } catch (IOException e) { e.printStackTrace(); } //Notices URL try { titlearray_n = new ArrayList<String>(); // ? URL Document doc = Jsoup.connect( "http://www.zion.hs.kr/main.php?" + "menugrp=110100&master=bbs&act=list&master_sid=58") .get(); //Get contents from tags,"a" which are in the class,"listbody" Elements rawmaindata = doc.select(".listbody a"); String titlestring = rawmaindata.toString(); Log.i("Notices", "Parsed Strings" + titlestring); // ?? ? for (Element el : rawmaindata) { String titledata = el.attr("title"); titlearray_n.add(titledata); // add value to ArrayList } Log.i("Notices", "Parsed Array Strings" + titlearray_n); } catch (IOException e) { e.printStackTrace(); } mHandler.post(new Runnable() { public void run() { // progressDialog.dismiss(); // SRL.setRefreshing(false); if (AMorPM == Calendar.AM) { MealString = lunchstring[DAYofWEEK - 1]; } else { MealString = dinnerstring[DAYofWEEK - 1]; } try { ScheduleString = schedulearray.get(DAYofMONTH - 1); NoticesParentString = titlearray_np.get(0); NoticeString = titlearray_n.get(0); } catch (Exception e) { ScheduleString = getResources().getString(R.string.error); NoticesParentString = getResources().getString(R.string.error); NoticeString = getResources().getString(R.string.error); } if (MealString == null) { MealString = getResources().getString(R.string.nodata); } else if (MealString.equals("")) { MealString = getResources().getString(R.string.nodata); } if (ScheduleString == null) { ScheduleString = getResources().getString(R.string.nodata); } else if (ScheduleString.equals("")) { ScheduleString = getResources().getString(R.string.nodata); } SRL.setRefreshing(false); handler.sendEmptyMessage(0); setContentData(); } }); } }.start(); }
From source file:com.massivekinetics.ow.ui.views.timepicker.TimePicker.java
private void updateAmPmControl() { if (is24HourView()) { if (mAmPmSpinner != null) { mAmPmSpinner.setVisibility(View.GONE); } else {/* w w w. j a v a2 s .c o m*/ 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); }
From source file:com.owncloud.android.ui.fragment.contactsbackup.ContactsBackupFragment.java
@Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity(); selectedDate = new Date(year, month, dayOfMonth); String backupFolderString = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;//from ww w .j a v a2 s .co m OCFile backupFolder = contactsPreferenceActivity.getStorageManager().getFileByPath(backupFolderString); Vector<OCFile> backupFiles = contactsPreferenceActivity.getStorageManager().getFolderContent(backupFolder, false); // find file with modification with date and time between 00:00 and 23:59 // if more than one file exists, take oldest Calendar date = Calendar.getInstance(); date.set(year, month, dayOfMonth); // start date.set(Calendar.HOUR, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 1); date.set(Calendar.MILLISECOND, 0); date.set(Calendar.AM_PM, Calendar.AM); Long start = date.getTimeInMillis(); // end date.set(Calendar.HOUR, 23); date.set(Calendar.MINUTE, 59); date.set(Calendar.SECOND, 59); Long end = date.getTimeInMillis(); OCFile backupToRestore = null; for (OCFile file : backupFiles) { if (start < file.getModificationTimestamp() && end > file.getModificationTimestamp()) { if (backupToRestore == null) { backupToRestore = file; } else if (backupToRestore.getModificationTimestamp() < file.getModificationTimestamp()) { backupToRestore = file; } } } if (backupToRestore != null) { Fragment contactListFragment = ContactListFragment.newInstance(backupToRestore, contactsPreferenceActivity.getAccount()); contactsPreferenceActivity.getSupportFragmentManager().beginTransaction() .replace(R.id.frame_container, contactListFragment, ContactListFragment.TAG) .addToBackStack(ContactsPreferenceActivity.BACKUP_TO_LIST).commit(); } else { Toast.makeText(contactsPreferenceActivity, R.string.contacts_preferences_no_file_found, Toast.LENGTH_SHORT).show(); } }
From source file:org.shengrui.oa.util.UtilDateTime.java
/** Makes a Timestamp for the beginning of the month * @return A Timestamp of the beginning of the month *//* w w w .j ava 2 s . c om*/ public static java.sql.Timestamp monthBegin() { Calendar mth = Calendar.getInstance(); mth.set(Calendar.DAY_OF_MONTH, 1); mth.set(Calendar.HOUR_OF_DAY, 0); mth.set(Calendar.MINUTE, 0); mth.set(Calendar.SECOND, 0); mth.set(Calendar.AM_PM, Calendar.AM); return new java.sql.Timestamp(mth.getTime().getTime()); }
From source file:com.concursive.connect.web.portal.PortalUtils.java
public static void populateObject(Object bean, ActionRequest request) { String nestedAttribute = "_"; Enumeration en = request.getParameterNames(); String paramName = null;/* w ww . ja v a 2 s. c om*/ while (en.hasMoreElements()) { paramName = (String) en.nextElement(); // a form has been submitted and requested to be auto-populated, // so we do that here..going through every element and trying // to call a setXXX() method on the bean object passed in for the value // of the request parameter currently being checked. String[] paramValues = request.getParameterValues(paramName); if (paramValues.length > 1) { ObjectUtils.setParam(bean, paramName, paramValues, nestedAttribute); } else { ObjectUtils.setParam(bean, paramName, paramValues[0], nestedAttribute); } } // TODO: currently for ticket and ticket history //ObjectUtils.invokeMethod(bean, "setRequestItems", new HttpRequestContext(request)); // Check for valid user User thisUser = (User) request.getAttribute(Constants.REQUEST_USER); if (thisUser != null) { // Populate date/time fields using the user's timezone and locale if (thisUser.getTimeZone() != null) { ArrayList timeParams = (ArrayList) ObjectUtils.getObject(bean, "TimeZoneParams"); if (timeParams != null) { Calendar cal = Calendar.getInstance(); Iterator i = timeParams.iterator(); while (i.hasNext()) { // The property that can be set String name = (String) i.next(); // See if it is in the request String value = request.getParameter(name); if (value != null) { // See if time is in request too String hourValue = request.getParameter(name + "Hour"); if (hourValue == null) { // Date fields: 1-1 mapping between HTML field and Java property ObjectUtils.setParam(bean, name, DateUtils.getUserToServerDateTimeString( TimeZone.getTimeZone(thisUser.getTimeZone()), DateFormat.SHORT, DateFormat.LONG, value, thisUser.getLocale())); } else { // Date & Time fields: 4-1 mapping between HTML fields and Java property try { Timestamp timestamp = DatabaseUtils.parseDateToTimestamp(value, thisUser.getLocale()); cal.setTimeInMillis(timestamp.getTime()); int hour = Integer.parseInt(hourValue); int minute = Integer.parseInt(request.getParameter(name + "Minute")); String ampmString = request.getParameter(name + "AMPM"); if (ampmString != null) { int ampm = Integer.parseInt(ampmString); if (ampm == Calendar.AM) { if (hour == 12) { hour = 0; } } else { if (hour < 12) { hour += 12; } } } cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal.setTimeZone(TimeZone.getTimeZone(thisUser.getTimeZone())); ObjectUtils.setParam(bean, name, new Timestamp(cal.getTimeInMillis())); } catch (Exception dateE) { } } } } } } // Populate number fields using the user's locale if (thisUser.getLocale() != null) { ArrayList numberParams = (ArrayList) ObjectUtils.getObject(bean, "NumberParams"); if (numberParams != null) { NumberFormat nf = NumberFormat.getInstance(thisUser.getLocale()); Iterator i = numberParams.iterator(); while (i.hasNext()) { // The property that can be set String name = (String) i.next(); // See if it is in the request String value = (String) request.getParameter(name); if (value != null && !"".equals(value)) { try { // Parse the value ObjectUtils.setParam(bean, name, nf.parse(value).doubleValue()); } catch (Exception e) { //e.printStackTrace(System.out); } } } } } } }
From source file:org.kuali.kfs.module.purap.document.service.impl.PurapServiceImpl.java
/** * @see org.kuali.kfs.module.purap.document.service.PurapService#isDateMoreThanANumberOfDaysAway(java.sql.Date, int) *//*from w w w .j a v a2 s . co m*/ @Override public boolean isDateMoreThanANumberOfDaysAway(Date compareDate, int daysAway) { LOG.debug("isDateMoreThanANumberOfDaysAway() started"); Date todayAtMidnight = dateTimeService.getCurrentSqlDateMidnight(); Calendar daysAwayCalendar = dateTimeService.getCalendar(todayAtMidnight); daysAwayCalendar.add(Calendar.DATE, daysAway); Timestamp daysAwayTime = new Timestamp(daysAwayCalendar.getTime().getTime()); Calendar compareCalendar = dateTimeService.getCalendar(compareDate); compareCalendar.set(Calendar.HOUR, 0); compareCalendar.set(Calendar.MINUTE, 0); compareCalendar.set(Calendar.SECOND, 0); compareCalendar.set(Calendar.MILLISECOND, 0); compareCalendar.set(Calendar.AM_PM, Calendar.AM); Timestamp compareTime = new Timestamp(compareCalendar.getTime().getTime()); return (compareTime.compareTo(daysAwayTime) > 0); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void init(Context context) { setFocusable(true);//from www . ja va 2 s. c o m // Allow focus in touch mode so that we can do keyboard shortcuts // even after we've entered touch mode. setFocusableInTouchMode(true); setClickable(true); setOnCreateContextMenuListener(this); mFirstDayOfWeek = Time.MONDAY; mCurrentTime = new Time(DayUtils.getTimeZone(context, mTZUpdater)); long currentTime = System.currentTimeMillis(); mCurrentTime.set(currentTime); mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.gmtoff); mEventTextPaint.setTextSize(EVENT_TEXT_FONT_SIZE); mEventTextPaint.setTextAlign(Align.LEFT); mEventTextPaint.setAntiAlias(true); int gridLineColor = 0xff707070; Paint p = mSelectionPaint; p.setColor(gridLineColor); p.setStyle(Style.FILL); p.setAntiAlias(false); p = mPaint; p.setAntiAlias(true); // Long day names mDayStrsLong = new String[14]; // Allocate space for 2 weeks worth of weekday names so that we can // easily start the week display at any week day. mDayStrs = new String[14]; // Also create an array of 2-letter abbreviations. mDayStrs2Letter = new String[14]; for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) { int index = i - Calendar.SUNDAY; mDayStrsLong[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase(); mDayStrsLong[index + 7] = mDayStrsLong[index]; // e.g. Tue for Tuesday mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM).toUpperCase(); mDayStrs[index + 7] = mDayStrs[index]; // e.g. Tu for Tuesday mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT).toUpperCase(); // If we don't have 2-letter day strings, fall back to 1-letter. if (mDayStrs2Letter[index].equals(mDayStrs[index])) { mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST); } mDayStrs2Letter[index + 7] = mDayStrs2Letter[index]; } // Figure out how much space we need for the 3-letter abbrev names // in the worst case. p.setTextSize(DATE_HEADER_FONT_SIZE); p.setTypeface(mBold); String[] dateStrs = { " 28", " 30" }; mDateStrWidth = computeMaxStringWidth(0, dateStrs, p); Time time = new Time(); time.setJulianDay(mFirstJulianDay); String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false))); mDateStrWidthLong = computeMaxStringWidth(0, new String[] { s }, p); p.setTextSize(DAY_HEADER_FONT_SIZE); mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p); mDateStrWidthLong += computeMaxStringWidth(0, mDayStrsLong, p); p.setTextSize(HOURS_TEXT_SIZE); p.setTypeface(null); handleOnResume(); mAmString = DateUtils.getAMPMString(Calendar.AM).toUpperCase(); mPmString = DateUtils.getAMPMString(Calendar.PM).toUpperCase(); String[] ampm = { mAmString, mPmString }; p.setTextSize(AMPM_TEXT_SIZE); mHoursWidth = Math.max(HOURS_MARGIN, computeMaxStringWidth(mHoursWidth, ampm, p) + HOURS_RIGHT_MARGIN); mHoursWidth = Math.max(MIN_HOURS_WIDTH, mHoursWidth); LayoutInflater inflater; inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); Resources.Theme dialogTheme = getResources().newTheme(); dialogTheme.applyStyle(android.R.style.Theme_Dialog, true); TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); // Catch long clicks for creating a new event mBaseDate = new Time(DayUtils.getTimeZone(context, mTZUpdater)); long millis = System.currentTimeMillis(); mBaseDate.set(millis); mEarliestStartHour = new int[mNumDays]; mHasAllDayEvent = new boolean[mNumDays]; // mLines is the array of points used with Canvas.drawLines() in // drawGridBackground() and drawAllDayEvents(). Its size depends // on the max number of lines that can ever be drawn by any single // drawLines() call in either of those methods. final int maxGridLines = (24 + 1) // max horizontal lines we might draw + (mNumDays + 1); // max vertical lines we might draw mLines = new float[maxGridLines * 4]; }
From source file:com.rogchen.common.xml.UtilDateTime.java
/** * Makes a Timestamp for the beginning of the month * * @return A Timestamp of the beginning of the month *//*from w w w.j a v a 2 s. co m*/ public static Timestamp monthBegin() { Calendar mth = Calendar.getInstance(); mth.set(Calendar.DAY_OF_MONTH, 1); mth.set(Calendar.HOUR_OF_DAY, 0); mth.set(Calendar.MINUTE, 0); mth.set(Calendar.SECOND, 0); mth.set(Calendar.MILLISECOND, 0); mth.set(Calendar.AM_PM, Calendar.AM); return new Timestamp(mth.getTime().getTime()); }
From source file:org.apache.orc.impl.mask.RedactMaskFactory.java
/** * Given the requested masking parameters, redact the given time * @param millis the original time/*from www . ja v a 2s. c o m*/ * @return the millis after it has been masked */ long maskTime(long millis) { scratch.setTimeInMillis(millis); if (YEAR_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.YEAR, YEAR_REPLACEMENT); } if (MONTH_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.MONTH, MONTH_REPLACEMENT - 1); } if (DATE_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.DATE, DATE_REPLACEMENT); } if (HOUR_REPLACEMENT != UNMASKED_DATE) { if (HOUR_REPLACEMENT >= 12) { scratch.set(Calendar.HOUR, HOUR_REPLACEMENT - 12); scratch.set(Calendar.AM_PM, Calendar.PM); } else { scratch.set(Calendar.HOUR, HOUR_REPLACEMENT); scratch.set(Calendar.AM_PM, Calendar.AM); } } if (MINUTE_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.MINUTE, MINUTE_REPLACEMENT); } if (SECOND_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.SECOND, SECOND_REPLACEMENT); scratch.set(Calendar.MILLISECOND, 0); } return scratch.getTimeInMillis(); }