List of usage examples for java.util Calendar MONTH
int MONTH
To view the source code for java.util Calendar MONTH.
Click Source Link
get
and set
indicating the month. From source file:com.google.code.rptm.mailarchive.YearMonth.java
/** * Construct a new instance with the year and month given by the current data. *///from ww w. ja va 2 s. co m public YearMonth() { GregorianCalendar cal = new GregorianCalendar(); year = cal.get(Calendar.YEAR); month = cal.get(Calendar.MONTH) + 1; }
From source file:ru.retbansk.utils.marshaller.Jaxb2MarshallerTest.java
@BeforeClass public static void beforeClass() { TaskReport taskReport = new TaskReport(); Date date = new Date(); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); calendar.clear();//from www .j a v a2 s . c om calendar.set(Calendar.DATE, 1); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.YEAR, 1981); date = calendar.getTime(); taskReport.setDate(date); taskReport.setElapsedTime(4); taskReport.setStatus(STATUS); taskReport.setWorkDescription(WORK_DESCRIPTION); list = new ArrayList<TaskReport>(); list.add(taskReport); }
From source file:cr.ac.siua.tec.utils.impl.CEInclusionPDFGenerator.java
/** * Fills the PDF file (inclusion.pdf) with the ticket values and returns base64 encoded string. *//*from w ww . j av a 2 s . c o m*/ @Override public String generate(HashMap<String, String> formValues) { String originalPdf = PDFGenerator.RESOURCES_PATH + "inclusion.pdf"; try { PDDocument _pdfDocument = PDDocument.load(originalPdf); PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); formValues.remove("Queue"); formValues.remove("Justificacin"); //Set some fields manually. Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; if (month > 10 || month < 5) acroForm.getField("Semestre").setValue("I"); else acroForm.getField("Semestre").setValue("II"); if (month > 10 && acroForm.getField("Semestre").getValue().equals("I")) year++; acroForm.getField("Ao").setValue(String.valueOf(year)); //Fills enrolled courses table. String enrolledCourses[] = formValues.get("Cursos matriculados").split("\n"); for (int i = 0; i < enrolledCourses.length; i++) { String courseRow[] = enrolledCourses[i].split("-"); acroForm.getField("Cdigo" + Integer.toString(i)).setValue(courseRow[0]); acroForm.getField("Curso" + Integer.toString(i)).setValue(courseRow[1]); acroForm.getField("Grupo" + Integer.toString(i)).setValue(courseRow[2]); } formValues.remove("Cursos matriculados"); //Iterates through remaining custom fields. for (Map.Entry<String, String> entry : formValues.entrySet()) { acroForm.getField(entry.getKey()).setValue(entry.getValue()); } return encodePDF(_pdfDocument); } catch (IOException e) { e.printStackTrace(); System.out.println("Excepcin al llenar el PDF."); return null; } }
From source file:JapaneseCalendar.java
public void paintComponent(Graphics g) { int width = 400; int height = 400; Calendar cal = Calendar.getInstance(locale); cal.setTime(new Date()); String header = cal.getDisplayName(Calendar.MONTH, Calendar.LONG, locale); header += " " + cal.get(Calendar.YEAR); FontMetrics fm = g.getFontMetrics(); Insets insets = getInsets();/* w ww. j av a 2s .c o m*/ g.setColor(Color.black); g.drawString(header, (width - fm.stringWidth(header)) / 2, insets.top + fm.getHeight()); DateFormatSymbols dfs = new DateFormatSymbols(locale); String[] weekdayNames = dfs.getShortWeekdays(); int fieldWidth = (width - insets.left - insets.right) / 7; g.drawString(weekdayNames[Calendar.SUNDAY], insets.left + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.SUNDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.MONDAY], insets.left + fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.MONDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.TUESDAY], insets.left + 2 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.TUESDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.WEDNESDAY], insets.left + 3 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.WEDNESDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.THURSDAY], insets.left + 4 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.THURSDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.FRIDAY], insets.left + 5 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.FRIDAY])) / 2, insets.top + 3 * fm.getHeight()); g.drawString(weekdayNames[Calendar.SATURDAY], insets.left + 6 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.SATURDAY])) / 2, insets.top + 3 * fm.getHeight()); int dom = cal.get(Calendar.DAY_OF_MONTH); cal.set(Calendar.DAY_OF_MONTH, 1); int col = 0; switch (cal.get(Calendar.DAY_OF_WEEK)) { case Calendar.MONDAY: col = 1; break; case Calendar.TUESDAY: col = 2; break; case Calendar.WEDNESDAY: col = 3; break; case Calendar.THURSDAY: col = 4; break; case Calendar.FRIDAY: col = 5; break; case Calendar.SATURDAY: col = 6; } cal.set(Calendar.DAY_OF_MONTH, dom); int row = 5 * fm.getHeight(); for (int i = 1; i <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); i++) { g.drawString("" + i, insets.left + fieldWidth * col + (fieldWidth - fm.stringWidth("" + i)) / 2, row); if (++col > 6) { col = 0; row += fm.getHeight(); } } }
From source file:view.PnIncome.java
/** * Creates new form PnHotel// w w w .ja v a2s. c o m */ public PnIncome() { this.mQuarter = Constant.MONTH_OF_QUARTER; initComponents(); pnFind.add(new PnIncomeFindMonth(), BorderLayout.CENTER); Calendar now = Calendar.getInstance(); drawDateChartMonth(now.get(Calendar.MONTH) + 1, now.get(Calendar.YEAR)); mPnIncomeFindMonth = new PnIncomeFindMonth(); mPnIncomeFindMonth.getCbMonth().addActionListener((ActionEvent e) -> { pnCenter.removeAll(); drawDateChartMonth((int) mPnIncomeFindMonth.getCbMonth().getSelectedItem(), (int) mPnIncomeFindMonth.getCbYear().getSelectedItem()); }); mPnIncomeFindMonth.getCbYear().addActionListener((ActionEvent e) -> { pnCenter.removeAll(); drawDateChartMonth((int) mPnIncomeFindMonth.getCbMonth().getSelectedItem(), (int) mPnIncomeFindMonth.getCbYear().getSelectedItem()); }); mPnIncomeFindQuarter = new PnIncomeFindQuarter(); mPnIncomeFindQuarter.getCbQuarter().addActionListener((ActionEvent e) -> { pnCenter.removeAll(); drawDateChartQuarter(Integer.parseInt((String) mPnIncomeFindQuarter.getCbQuarter().getSelectedItem()), (int) mPnIncomeFindQuarter.getCbYear().getSelectedItem()); }); mPnIncomeFindQuarter.getCbYear().addActionListener((ActionEvent e) -> { pnCenter.removeAll(); drawDateChartQuarter((int) mPnIncomeFindQuarter.getCbQuarter().getSelectedItem(), (int) mPnIncomeFindQuarter.getCbYear().getSelectedItem()); }); mPnIncomeFindYear = new PnIncomeFindYear(); mPnIncomeFindYear.getCbYear().addActionListener((ActionEvent e) -> { pnCenter.removeAll(); drawDateChartYear((int) mPnIncomeFindYear.getCbYear().getSelectedItem()); }); }
From source file:com.aw.core.format.FechaEnTextoFormatter.java
public Object format(Object attributeValue) { Date date = (Date) attributeValue; Calendar cal = new GregorianCalendar(); cal.setTime(date);//from w ww . ja v a 2s.co m int anio = cal.get(Calendar.YEAR); int mes = cal.get(Calendar.MONTH); int dia = cal.get(Calendar.DAY_OF_MONTH); Map meses = buildMesesMap(); String valor = dia + " de " + meses.get(mes) + " del " + anio; return valor; }
From source file:com.xumpy.thuisadmin.controllers.model.FinanceHeader.java
public FinanceHeader() { SimpleDateFormat dt = new SimpleDateFormat("dd/MM/yyyy"); Date dateToday = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(dateToday);//from www.j a v a 2 s. co m cal.add(Calendar.MONTH, -1); Date prevMonth = cal.getTime(); this.beginDatum = dt.format(prevMonth); this.eindDatum = dt.format(dateToday); }
From source file:com.collabnet.ccf.core.utils.DateUtil.java
public static Date convertDateToTimeZone(Date date, String toTimeZone) { Calendar toCal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone)); Calendar fromCal = new GregorianCalendar(); fromCal.setTime(date);//from w ww .j a v a2 s .co m toCal.set(fromCal.get(Calendar.YEAR), fromCal.get(Calendar.MONTH), fromCal.get(Calendar.DAY_OF_MONTH), fromCal.get(Calendar.HOUR_OF_DAY), fromCal.get(Calendar.MINUTE), fromCal.get(Calendar.SECOND)); toCal.set(Calendar.MILLISECOND, fromCal.get(Calendar.MILLISECOND)); return toCal.getTime(); }
From source file:net.audumla.astronomy.SeasonTest.java
@Test public void testWinterStart() throws Exception { SeasonalEvent event = new SeasonalEvent(SeasonalEvent.WINTERSTART, Geolocation.newGeoLocation(30, 0, 0)); Date et = event.calculateEventFrom(new Date()); assert DateUtils.toCalendar(et).get(Calendar.MONTH) == Calendar.DECEMBER; event = new SeasonalEvent(SeasonalEvent.WINTERSTART, Geolocation.newGeoLocation(-30, 0, 0)); et = event.calculateEventFrom(new Date()); assert DateUtils.toCalendar(et).get(Calendar.MONTH) == Calendar.JUNE; }
From source file:com.epam.cme.storefront.forms.validation.PaymentDetailsValidator.java
@Override public void validate(final Object object, final Errors errors) { final PaymentDetailsForm form = (PaymentDetailsForm) object; if (StringUtils.isNotBlank(form.getStartMonth()) && StringUtils.isNotBlank(form.getStartYear()) && StringUtils.isNotBlank(form.getExpiryMonth()) && StringUtils.isNotBlank(form.getExpiryYear())) { final Calendar start = Calendar.getInstance(); start.set(Calendar.DAY_OF_MONTH, 0); start.set(Calendar.MONTH, Integer.parseInt(form.getStartMonth()) - 1); start.set(Calendar.YEAR, Integer.parseInt(form.getStartYear()) - 1); final Calendar expiration = Calendar.getInstance(); expiration.set(Calendar.DAY_OF_MONTH, 0); expiration.set(Calendar.MONTH, Integer.parseInt(form.getExpiryMonth()) - 1); expiration.set(Calendar.YEAR, Integer.parseInt(form.getExpiryYear()) - 1); if (start.after(expiration)) { errors.rejectValue("startMonth", "payment.startDate.invalid"); }/*from w ww . j ava2s . c o m*/ } final boolean editMode = StringUtils.isNotBlank(form.getPaymentId()); if (editMode || Boolean.TRUE.equals(form.getNewBillingAddress())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.titleCode", "address.title.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName", "address.firstName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName", "address.lastName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity", "address.townCity.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode", "address.postcode.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso", "address.country.invalid"); // ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line2", // "address.line2.invalid"); // for some addresses this field is required by cybersource } }