List of usage examples for java.util GregorianCalendar GregorianCalendar
public GregorianCalendar()
GregorianCalendar
using the current time in the default time zone with the default Locale.Category#FORMAT FORMAT locale. From source file:com.esofthead.mycollab.core.persistence.service.DefaultCrudService.java
@Override public int saveWithSession(T record, String username) { if (!StringUtils.isBlank(username)) { try {/*ww w. j av a2 s .c o m*/ PropertyUtils.setProperty(record, "createduser", username); } catch (Exception e) { } } try { PropertyUtils.setProperty(record, "createdtime", new GregorianCalendar().getTime()); PropertyUtils.setProperty(record, "lastupdatedtime", new GregorianCalendar().getTime()); } catch (Exception e) { } getCrudMapper().insertAndReturnKey(record); try { return (Integer) PropertyUtils.getProperty(record, "id"); } catch (Exception e) { return 0; } }
From source file:eu.impress.repository.util.EDXLlib.java
public static XMLGregorianCalendar getXMLGregorianCalendar() throws DatatypeConfigurationException { try {//from w w w . j a va 2 s . c o m Date now = new Date(); GregorianCalendar c = new GregorianCalendar(); c.setTime(now); XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); return date2; } catch (DatatypeConfigurationException c) { return null; } }
From source file:eu.openminted.registry.service.generate.WorkflowOutputMetadataGenerate.java
public WorkflowOutputMetadataGenerate() { mapper = new ObjectMapper(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.setDateFormat(new ISO8601DateFormat()); gregory = new GregorianCalendar(); gregory.setTime(new java.util.Date()); }
From source file:com.mycollab.aspect.InjectTimeLoggingAspect.java
@Before("(execution(public * com.mycollab..service..*.updateWithSession(..)) || (execution(public * com.mycollab..service..*.updateSelectiveWithSession(..)))) && args(bean, username)") public void injectDateForUpdateMethod(JoinPoint joinPoint, Object bean, String username) { try {/* w w w . j a va 2 s . c om*/ LOG.debug("Set createtime and lastupdatedtime if enable"); PropertyUtils.setProperty(bean, "lastupdatedtime", new GregorianCalendar().getTime()); } catch (Exception e) { } }
From source file:org.openehealth.coala.converter.PXSDateConverterTest.java
/** * @throws java.lang.Exception//ww w . ja v a 2 s . co m */ @Before public void setUp() throws Exception { ResourceBundle properties = ResourceBundle.getBundle("coala-document"); longPattern = properties.getString("coala.consent.longdatepattern"); shortPattern = properties.getString("coala.consent.shortdatepattern"); GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR, 3); cal.set(Calendar.MINUTE, 36); cal.set(Calendar.SECOND, 50); cal.set(Calendar.MILLISECOND, 0); referenceDateLong = cal.getTime(); cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2011); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); referenceDateShort = cal.getTime(); }
From source file:edu.umm.radonc.ca_dash.controllers.PieChartController.java
public PieChartController() { endDate = new Date(); this.interval = ""; GregorianCalendar gc = new GregorianCalendar(); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Map<String, Object> sessionMap = externalContext.getSessionMap(); if (sessionMap.containsKey("endDate")) { endDate = (Date) sessionMap.get("endDate"); } else {/*from w w w. j a v a 2 s. c o m*/ endDate = new Date(); sessionMap.put("endDate", endDate); } if (sessionMap.containsKey("startDate")) { startDate = (Date) sessionMap.get("startDate"); } else { gc.setTime(endDate); gc.add(Calendar.MONTH, -1); startDate = gc.getTime(); sessionMap.put("startDate", startDate); this.interval = "1m"; } this.df = new SimpleDateFormat("MM/dd/YYYY"); this.decf = new DecimalFormat("###.###"); this.decf.setRoundingMode(RoundingMode.HALF_UP); this.selectedFacility = new Long(-1); this.dstats = new SynchronizedDescriptiveStatistics(); this.dstatsPerDoc = new TreeMap<>(); this.dstatsPerRTM = new TreeMap<>(); this.pieChart = new PieChartModel(); selectedFilters = "all-tx"; }
From source file:CalendarUtils.java
/** * See the other round method. Works with a Date object. *//*from www.j ava 2 s .co m*/ public static Date round(Date val, int field) { GregorianCalendar gval = new GregorianCalendar(); gval.setTime(val); modify(gval, field, true); return gval.getTime(); }
From source file:com.esofthead.mycollab.common.interceptor.aspect.InjectTimeLoggingAspect.java
@Before("(execution(public * com.esofthead.mycollab..service..*.updateWithSession(..)) || (execution(public * com.esofthead.mycollab..service..*.updateSelectiveWithSession(..)))) && args(bean, username)") public void injectDateForUpdateMethod(JoinPoint joinPoint, Object bean, String username) { try {// w w w. j a v a2 s .c o m LOG.debug("Set createtime and lastupdatedtime if enable"); PropertyUtils.setProperty(bean, "lastupdatedtime", new GregorianCalendar().getTime()); } catch (Exception e) { } }
From source file:com.esofthead.mycollab.common.interceptor.aspect.TraceableAspect.java
static ActivityStreamWithBLOBs constructActivity(Class<?> cls, Traceable traceableAnnotation, Object bean, String username, String action) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { ActivityStreamWithBLOBs activity = new ActivityStreamWithBLOBs(); activity.setModule(ClassInfoMap.getModule(cls)); activity.setType(ClassInfoMap.getType(cls)); activity.setTypeid(String.valueOf(PropertyUtils.getProperty(bean, traceableAnnotation.idField()))); activity.setCreatedtime(new GregorianCalendar().getTime()); activity.setAction(action);/*from w w w. j a v a 2 s. c o m*/ activity.setSaccountid((Integer) PropertyUtils.getProperty(bean, "saccountid")); activity.setCreateduser(username); Object nameObj = PropertyUtils.getProperty(bean, traceableAnnotation.nameField()); String nameField; if (nameObj instanceof Date) { nameField = DateTimeUtils.formatDate((Date) nameObj, "MM/dd/yyyy"); } else { nameField = nameObj.toString(); } activity.setNamefield(nameField); if (!"".equals(traceableAnnotation.extraFieldName())) { Integer extraTypeId = (Integer) PropertyUtils.getProperty(bean, traceableAnnotation.extraFieldName()); activity.setExtratypeid(extraTypeId); } return activity; }
From source file:it.marcoberri.mbmeteo.action.chart.Base.java
/** * * @param from//from w w w . ja va 2 s . c om * @param to * @return */ protected List<Date> getRangeDate(Date from, Date to) { final List<Date> dates = new ArrayList<Date>(); final Calendar calendar = new GregorianCalendar(); calendar.setTime(from); while (calendar.getTime().before(to)) { Date resultado = calendar.getTime(); dates.add(resultado); calendar.add(Calendar.DATE, 1); } return dates; }