List of usage examples for java.util GregorianCalendar GregorianCalendar
GregorianCalendar(TimeZone zone, Locale locale, boolean flag)
From source file:com.chadekin.jadys.commons.expression.SqlValueFormatterFactoryTest.java
@Test public void shouldFormatDateValue() { // Arrange//from w w w. ja va 2 s . c om Calendar calendar = new GregorianCalendar(2016, Calendar.DECEMBER, 24); Object value = calendar.getTime(); // Act String result = SqlValueFormatterFactory.format(value).build(); // Assert assertThat(result, is("'2016-12-24'")); }
From source file:fr.xebia.demo.ws.employee.EmployeeServiceImpl.java
@Override public Employee getEmployee(int id) throws EmployeeServiceFaultMsg { Employee employee = new Employee(); employee.setId(id);//from w w w .j ava2 s . c o m employee.setLastName("Doe"); employee.setFirstName("John"); employee.setGender(Gender.MALE); employee.setBirthdate(new Date(new GregorianCalendar(1976, 01, 05).getTimeInMillis())); logger.info("getEmployee(" + id + "): " + ToStringBuilder.reflectionToString(employee)); return employee; }
From source file:datojava.jcalendar.DJJCalendar.java
public void fechasOcupadas() throws IOException, ClientProtocolException, JSONException, ParseException { for (int i = 0; i < fechasOcupadasArray.length(); i++) { JSONObject obj = (JSONObject) fechasOcupadasArray.get(i); //Date date = formato.parse(obj.get("diasOcupados").toString()); LocalDate date = LocalDate.parse(obj.get("diasOcupados").toString(), formatter); Calendar calendar = new GregorianCalendar(date.getYear(), date.getMonthValue() - 1, date.getDayOfMonth());/*from w ww. ja v a 2s.c o m*/ //Calendar calendar = new GregorianCalendar(2015,Calendar.DECEMBER,12); fechasOcupadas.add(calendar); } System.out.println("retorne el djj"); }
From source file:no.dusken.aranea.service.TestIssueServiceImpl.java
@Before public void onSetup() { issue = new Issue(); issue.setIssue(1);/*w w w. ja v a 2 s . c o m*/ Calendar from = new GregorianCalendar(2007, 01, 1); Calendar to = new GregorianCalendar(2007, 05, 1); issue.setFromDate(from); issue.setToDate(to); issue.setTimeCreated(to); issue.setDescription("#UD 01"); issue = issueService.saveOrUpdate(issue); Issue issue2 = new Issue(); issue2.setIssue(1); Calendar from2 = new GregorianCalendar(2007, 05, 1); Calendar to2 = new GregorianCalendar(2007, 11, 11); issue2.setFromDate(from2); issue2.setToDate(to2); issue2.setTimeCreated(to); issue2.setDescription("#UD 01"); issue2 = issueService.saveOrUpdate(issue2); }
From source file:com.baidu.rigel.biplatform.ac.util.TimeDimensionUtils.java
/** * ??/*from ww w . j ava 2s. com*/ * * @param timeStr * @param timeType ?? * @param timeFormat ?? * @return timeMember ?member * @throws ParseException parse? */ public static MiniCubeMember createTimeMember(String timeStr, TimeType timeType, String timeFormat) throws ParseException { if (StringUtils.isBlank(timeStr) && timeType == null) { throw new IllegalArgumentException( "timeStr is blank or timeType is null, timeStr:" + timeStr + " timeType:" + timeType); } Calendar calendar = null; String dateFormat = StringUtils.isBlank(timeFormat) ? timeType.getFormat() : timeFormat; if (dateFormat.toUpperCase().contains("QN")) { int year = Integer.parseInt(timeStr.substring(0, 4)); int quarter = Integer.parseInt(timeStr.substring(5)); // Calendar?1 int month = (quarter - 1) * 3; calendar = new GregorianCalendar(year, month, 1); } else { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); Date date = sdf.parse(timeStr); calendar = Calendar.getInstance(); calendar.setTime(date); } int quarter = calendar.get(Calendar.MONTH) / 3 + 1; String caption = null; MiniCubeLevel level = new MiniCubeLevel("level_" + timeType); if (timeType.equals(TimeType.TimeYear)) { caption = calendar.get(Calendar.YEAR) + ""; level.setType(LevelType.TIME_YEARS); } else if (timeType.equals(TimeType.TimeQuarter)) { caption = calendar.get(Calendar.YEAR) + "_Q" + quarter; level.setType(LevelType.TIME_QUARTERS); } else if (timeType.equals(TimeType.TimeMonth)) { caption = calendar.get(Calendar.YEAR) + "_" + (calendar.get(Calendar.MONTH) + 1); level.setType(LevelType.TIME_MONTHS); } else if (timeType.equals(TimeType.TimeWeekly)) { caption = calendar.get(Calendar.YEAR) + "_W" + calendar.get(Calendar.WEEK_OF_YEAR); level.setType(LevelType.TIME_WEEKS); } else if (timeType.equals(TimeType.TimeDay)) { caption = DEFAULT_SIMPLE_DATEFORMAT.format(calendar.getTime()); level.setType(LevelType.TIME_DAYS); } MiniCubeMember member = new MiniCubeMember(timeStr); member.setCaption(caption); member.setVisible(true); member.setLevel(level); LOG.info("time member:" + member); return member; }
From source file:com.cognitivabrasil.repositorio.data.entities.DocumentTest.java
@Test public void testTimestamp() { Document d = new Document(); d.setCreated(new DateTime(1984, 8, 21, 0, 0, 0)); assertThat(d.getTimestamp(), equalTo(new GregorianCalendar(1984, GregorianCalendar.AUGUST, 21).getTime())); }
From source file:be.vdab.util.Datum.java
@Override public int compareTo(Datum d) { Calendar datum1 = new GregorianCalendar(jaar, maand - 1, dag); Calendar datum2 = new GregorianCalendar(d.jaar, d.maand - 1, d.dag); //System.out.println("compareTo: " + datum1.compareTo(datum2)); return datum1.compareTo(datum2); }
From source file:no.dusken.aranea.service.ArticleServiceImpl.java
public List<Article> getArticlesByYear(int year, int number, int offset) { List<Article> list = Collections.emptyList(); try {/*from ww w. j a v a 2s . c o m*/ Map<String, Object> map = new HashMap<String, Object>(); map.put("fromDate", new GregorianCalendar(year, 0, 1)); map.put("toDate", new GregorianCalendar(year, 11, 31)); list = genericDao.getByNamedQuery("article_byyear", map, offset, number); } catch (DataAccessException dae) { log.info("Unable to get Articles", dae); } return list; }
From source file:io.github.seiferma.jameica.hibiscus.dkb.creditcard.synchronize.csvparser.DKBCsvParserTest.java
@Test public void testGetSaldoDate() throws IOException { assertEquals(new GregorianCalendar(2016, 11, 27).getTime(), subject.getBalanceDate()); }
From source file:no.dusken.aranea.service.IssueServiceImpl.java
public List<Issue> getIssuesPublished(int year) { List<Issue> i = Collections.emptyList(); try {/*from w ww . j av a2s. c om*/ Map<String, Object> map = new HashMap<String, Object>(); map.put("fromDate", new GregorianCalendar(year, 0, 1)); GregorianCalendar endOfYear = new GregorianCalendar(year, 11, 31); GregorianCalendar today = new GregorianCalendar(); if (endOfYear.after(today)) { map.put("toDate", today); } else { map.put("toDate", endOfYear); } i = genericDao.getByNamedQuery("issues_byyear_published", map); } catch (DataAccessException dae) { log.warn("Unable to get Issues", dae); } return i; }