List of usage examples for java.util GregorianCalendar set
public final void set(int year, int month, int date)
YEAR
, MONTH
, and DAY_OF_MONTH
. From source file:Calendar.java
public void setMonth(int year, int month) { for (int i = 1; i < 7; ++i) for (int j = 0; j < 7; ++j) calendar[i][j] = " "; java.util.GregorianCalendar cal = new java.util.GregorianCalendar(); cal.set(year, month, 1); int offset = cal.get(java.util.GregorianCalendar.DAY_OF_WEEK) - 1; offset += 7;/* w w w . j a va2 s .com*/ int num = daysInMonth(year, month); for (int i = 0; i < num; ++i) { calendar[offset / 7][offset % 7] = Integer.toString(i + 1); ++offset; } }
From source file:com.atolcd.alfresco.audit.web.scripts.ConnectionLogsGet.java
private GregorianCalendar getDateFromString(String s_date, String separator) { String[] date = new String[3]; int cpt = 0;/*from w w w .j ava2 s. co m*/ java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(s_date, separator); while (tokenizer.hasMoreTokens()) { date[cpt] = tokenizer.nextToken().toString(); cpt++; } GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Integer.parseInt(date[2]), Integer.parseInt(date[1]) - 1, Integer.parseInt(date[0])); return calendar; }
From source file:org.apache.torque.generated.peer.DefaultValuesFromJavaTest.java
/** * Checks that if CURRENT_TIME is used as default value * then an object is constructed with current java time. * * @throws Exception if an error occurs. */// w w w . j av a 2 s .c o m public void testCurrentTimeAsJavaDefault() throws Exception { if (defaultAdapter instanceof OracleAdapter || defaultAdapter instanceof MssqlAdapter || defaultAdapter instanceof MysqlAdapter) { log.error("testCurrentTimeAsJavaDefault(): " + "Oracle, MSSQL and Mysql do not support " + "the CURRENT_TIME function"); return; } GregorianCalendar currentCalendarBefore = new GregorianCalendar(); currentCalendarBefore.set(1970, 1, 1); JavaDefaultValues javaDefaultValues = new JavaDefaultValues(); GregorianCalendar currentCalendarAfter = new GregorianCalendar(); currentCalendarAfter.set(1970, 1, 1); assertFalse("currentTime should be >= currentCalendarBefore", javaDefaultValues.getCurrentTimeValue().before(currentCalendarBefore.getTime())); assertFalse("currentTime should be <= currentDateAfter", javaDefaultValues.getCurrentTimeValue().after(currentCalendarAfter.getTime())); }
From source file:com.sami.chart.util.LineChartDemo1.java
private CategoryDataset createDataset(boolean a) { final String series1 = "First"; final String series2 = "Second"; final String series3 = "Third"; GregorianCalendar gc = new GregorianCalendar(); gc.set(2007, 9, 7); // Date yesterday = new Date(System.currentTimeMillis() - 86400000); Date yesterday = gc.getTime(); DateChecker checker = new DateChecker(); checker.setDate(yesterday);/* w w w. j av a 2 s . co m*/ final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); try { TempReader reader = (TempReader) getClass().forName(getProperty("reader.Class")).newInstance(); String line = ""; while ((line = reader.readLine()) != null) { if (checker.isFromToday(line)) { String[] items = line.split(","); dataset.addValue(Float.parseFloat(items[1]), series1, items[0]); dataset.addValue(Float.parseFloat(items[2]), series2, items[0]); dataset.addValue(Float.parseFloat(items[3]), series3, items[0]); } } } catch (Exception e) { e.printStackTrace(); } return dataset; }
From source file:fr.univlorraine.ecandidat.controllers.DemoController.java
/** * @param ine//from w ww. ja va2 s . com * @return un individu Apogee anonyme */ public WSIndividu recupInfoEtudiant(String ine) { WSIndividu ind = null; GregorianCalendar cal = new GregorianCalendar(); cal.set(1992, 2, 12); if (ine != null && ine.equals("000000000") || ine.equals("1111111111") || ine.equals("2222222222") || ine.equals("3333333333") || ine.equals("4444444444") || ine.equals("5555555555") || ine.equals("6666666666") || ine.equals("7777777777") || ine.equals("8888888888") || ine.equals("9999999999")) { String cpt = ine.substring(0, 1); ind = new WSIndividu(1, "1", "057", new BigDecimal(ine), ine, "A", "D", cal.getTime(), "NomPat-" + cpt, "NomUsu-" + cpt, "Prenom1-" + cpt, "Prenom2-" + cpt, "Metz", "100"); ind.setAdresse(new WSAdresse(1, "57000", "57463", "100", "15 rue de Nancy", "Etage 1", "Porte droite", "0383542120", "0612356421")); ind.setBac(new WSBac(new Long(ine), "S", "057", "0573227Y", null, "2009", "O")); List<WSCursusInterne> listCursusInterne = new ArrayList<WSCursusInterne>(); listCursusInterne.add(new WSCursusInterne("VET001-001", "License 1 - Droit", "2010", "AB", "1")); listCursusInterne.add(new WSCursusInterne("VET001-002", "License 2 - Droit", "2011", "P", "1")); listCursusInterne.add(new WSCursusInterne("VET001-003", "License 2 - Droit", "2012", "P", "1")); listCursusInterne.add(new WSCursusInterne("VET001-004", "Master 1 - Droit", "2013", "B", "1")); listCursusInterne.add(new WSCursusInterne("VET001-005", "Master 2 - Droit", "2014", "P", "1")); ind.setListCursusInterne(listCursusInterne); } return ind; }
From source file:ca.uhn.hl7v2.model.primitive.tests.CommonDTTest.java
/** * Testing toHl7DTFormat() with a calendar */// w w w . j av a 2 s. com @Test public void testConvertCalToHL7DateFormat() throws DataTypeException { GregorianCalendar cal = new GregorianCalendar(); cal.clear(); cal.setLenient(false); cal.set(2002, 5, 24); String convertedDate = CommonDT.toHl7DTFormat(cal); assertEquals("20020624", convertedDate); }
From source file:com.eryansky.common.utils.DateUtil.java
/** * ?2009-08-01//from ww w . j a v a 2 s .c o m */ public static String addMonth(String strdate) { Date date = new Date(); // ?? String dateresult = null; // // ?? SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // ? GregorianCalendar gc = new GregorianCalendar(); try { date = df.parse(strdate); // ? } catch (ParseException e) { e.printStackTrace(); } gc.setTime(date); // gc? gc.add(2, 1); // 2?1?(,) // ? gc.set(gc.get(gc.YEAR), gc.get(gc.MONTH), gc.get(gc.DATE)); // ? dateresult = df.format(gc.getTime()); return dateresult; }
From source file:com.eryansky.common.utils.DateUtil.java
/** * ? ?2009-08-01//from w ww . ja va 2 s . com */ public static String subMonth(String strdate) { Date date = new Date(); // ?? String dateresult = null; // // ?? SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // ? GregorianCalendar gc = new GregorianCalendar(); try { date = df.parse(strdate); // ? } catch (ParseException e) { e.printStackTrace(); } gc.setTime(date); // gc? gc.add(2, -1); // 2?1?(,) // ? gc.set(gc.get(gc.YEAR), gc.get(gc.MONTH), gc.get(gc.DATE)); // ? dateresult = df.format(gc.getTime()); return dateresult; }
From source file:com.eryansky.common.utils.DateUtil.java
/** * ?2009-08-01//from w w w . j ava 2s . c om */ public static String addDay(String strdate) { Date date = new Date(); // ?? String dateresult = null; // // ?? SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // ? GregorianCalendar gc = new GregorianCalendar(); try { date = df.parse(strdate); // ? } catch (ParseException e) { e.printStackTrace(); } gc.setTime(date); // gc? gc.add(5, 1); // 2?1?(....5) // ? gc.set(gc.get(gc.YEAR), gc.get(gc.MONTH), gc.get(gc.DATE)); // ? dateresult = df.format(gc.getTime()); return dateresult; }
From source file:com.eryansky.common.utils.DateUtil.java
/** * ? ?2009-08-01// w w w . j a v a 2s. co m */ public static String subDay(String strdate) { Date date = new Date(); // ?? String dateresult = null; // // ?? SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // ? GregorianCalendar gc = new GregorianCalendar(); try { date = df.parse(strdate); // ? } catch (ParseException e) { e.printStackTrace(); } gc.setTime(date); // gc? gc.add(5, -1); // 2?1?(....5) // ? gc.set(gc.get(gc.YEAR), gc.get(gc.MONTH), gc.get(gc.DATE)); // ? dateresult = df.format(gc.getTime()); return dateresult; }