List of usage examples for java.util Calendar YEAR
int YEAR
To view the source code for java.util Calendar YEAR.
Click Source Link
get
and set
indicating the year. From source file:WebCalendar.java
/** */ public void setYear(int _iYear) { m_gc.set(Calendar.YEAR, _iYear); }
From source file:com.eryansky.common.utils.DateUtil.java
/** * ? ?2009-08-01// w ww . j a v a2 s . c o m */ public static String monthFist() { Calendar localTime = Calendar.getInstance(); String strY = null;// int x = localTime.get(Calendar.YEAR); // int y = localTime.get(Calendar.MONTH) + 1; // strY = y >= 10 ? String.valueOf(y) : ("0" + y); // ? return x + "-" + strY + "-01"; // ???yyyy-mm-dd? }
From source file:Main.java
private static String getCurrentTime() { Calendar calendar = Calendar.getInstance(); String strTime = String.format("%4d-%02d-%02d %02d:%02d:%02d", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); return strTime; }
From source file:facebook4j.internal.util.z_F4JInternalStringUtilTest.java
@Test public void formatISO8601Datetime() throws Exception { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2012); cal.set(Calendar.MONTH, 5);//from w w w .j a v a 2s. c om cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR_OF_DAY, 16); cal.set(Calendar.MINUTE, 17); cal.set(Calendar.SECOND, 18); cal.set(Calendar.MILLISECOND, 0); cal.setTimeZone(TimeZone.getTimeZone("JST")); String actual1 = z_F4JInternalStringUtil.formatISO8601Datetime(cal); assertThat(actual1, is("2012-06-15T16:17:18+0900")); cal.setTimeZone(TimeZone.getTimeZone("UTC")); String actual2 = z_F4JInternalStringUtil.formatISO8601Datetime(cal); assertThat(actual2, is("2012-06-15T07:17:18+0000")); //16-9=7 JSONObject json = new JSONObject( "{\"datetime1\": \"" + actual1 + "\", \"datetime2\": \"" + actual2 + "\"}"); Date d1 = z_F4JInternalParseUtil.getISO8601Datetime("datetime1", json); Date d2 = z_F4JInternalParseUtil.getISO8601Datetime("datetime2", json); assertThat(d1, is(d2)); }
From source file:net.seratch.taskun.util.CalendarUtil.java
public static Calendar getCalendar(String yyyy, String mm, String dd) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, Integer.valueOf(yyyy)); cal.set(Calendar.MONTH, Integer.valueOf(mm) - 1); cal.set(Calendar.DATE, Integer.valueOf(dd)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*from w w w. ja v a2 s .c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; }
From source file:helper.lang.DateHelperTest.java
@Test public void testAsUtcDayCalendar() { Calendar localTime = Calendar.getInstance(TimeZone.getTimeZone("CST")); Calendar cal = DateHelper.asUtcDay(localTime); assertEquals(0, cal.get(Calendar.MILLISECOND)); assertEquals(0, cal.get(Calendar.MINUTE)); assertEquals(0, cal.get(Calendar.HOUR)); assertEquals(0, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(DateHelper.UTC_TIME_ZONE, cal.getTimeZone()); assertEquals(TimeZone.getTimeZone("CST"), localTime.getTimeZone()); assertEquals(localTime.get(Calendar.YEAR), cal.get(Calendar.YEAR)); assertEquals(localTime.get(Calendar.MONTH), cal.get(Calendar.MONTH)); assertEquals(localTime.get(Calendar.DATE), cal.get(Calendar.DATE)); }
From source file:cr.ac.siua.tec.utils.impl.AssistancePDFGenerator.java
/** * Fills the PDF file (asistente.pdf) with the ticket values and returns base64 encoded string. *//*from w w w . j a v a2s.c om*/ @Override public String generate(HashMap<String, String> formValues) { String originalPdf = PDFGenerator.RESOURCES_PATH + "asistente.pdf"; try { PDDocument _pdfDocument = PDDocument.load(originalPdf); PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); //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("PRIMER"); else acroForm.getField("Semestre").setValue("SEGUNDO"); if (month > 10 && acroForm.getField("Semestre").getValue().equals("PRIMER")) year++; acroForm.getField("Ao").setValue(String.valueOf(year)); formValues.remove("Queue"); acroForm.getField(formValues.get("Banco")).setValue("x"); formValues.remove("Banco"); acroForm.getField(formValues.get("Tipo de asistencia")).setValue("x"); formValues.remove("Tipo de asistencia"); //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:com.liusoft.dlog4j.util.DateUtils.java
/** * ??/*from w w w . j a v a 2 s. c o m*/ * @param year * @param month * @param date * @return */ public static Calendar getDateBegin(int year, int month, int date) { Calendar begin_time = Calendar.getInstance(); begin_time.set(Calendar.YEAR, year); begin_time.set(Calendar.MONTH, month - 1); begin_time.set(Calendar.DATE, date); begin_time.set(Calendar.HOUR_OF_DAY, 0); begin_time.set(Calendar.MINUTE, 0); begin_time.set(Calendar.SECOND, 0); begin_time.set(Calendar.MILLISECOND, 0); return begin_time; }
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 w ww . j a v a 2 s . c o m*/ public YearMonth() { GregorianCalendar cal = new GregorianCalendar(); year = cal.get(Calendar.YEAR); month = cal.get(Calendar.MONTH) + 1; }
From source file:com.meltmedia.cadmium.copyright.service.CopyrightResourceHandler.java
/** * Initializes this instance with the current year. *//*from w ww . java2 s. c o m*/ public CopyrightResourceHandler() { year = Calendar.getInstance().get(Calendar.YEAR); log.debug("Updating all copyrights on site to {}", year); }