Package java.util

Examples of java.util.Calendar


        }
       
        //start with base time
        long time = date.getTime();
       
        Calendar cal = Calendar.getInstance(initial);
        cal.setTimeInMillis(time);

        target.clear();
        for (int i = 0; i <= Calendar.MILLISECOND; i++) {
            target.set(i, cal.get(i));
        }               
    }
View Full Code Here


     */
    public void helpTestChange(String ts,
                               String endtz,
                               String expected) {
        Timestamp start = Timestamp.valueOf(ts);
        Calendar target = Calendar.getInstance(TimeZone.getTimeZone(endtz));
        assertEquals(expected,
                     TimestampWithTimezone.createTimestamp(start, TimeZone.getTimeZone("America/Chicago"), target).toString()); //$NON-NLS-1$        
    }
View Full Code Here

    public void testCreateDate() {
        Timestamp t = Timestamp.valueOf("2004-06-30 23:39:10.1201"); //$NON-NLS-1$
        Date date = TimestampWithTimezone.createDate(t);
       
        Calendar cal = Calendar.getInstance();
       
        cal.setTimeInMillis(date.getTime());
       
        assertEquals(cal.get(Calendar.HOUR_OF_DAY), 0);
        assertEquals(cal.get(Calendar.MINUTE), 0);
        assertEquals(cal.get(Calendar.SECOND), 0);
        assertEquals(cal.get(Calendar.MILLISECOND), 0);
        assertEquals(cal.get(Calendar.YEAR), 2004);
        assertEquals(cal.get(Calendar.MONTH), Calendar.JUNE);
        assertEquals(cal.get(Calendar.DATE), 30);
    }
View Full Code Here

   
    public void testCreateTime() {
        Timestamp t = Timestamp.valueOf("2004-06-30 23:39:10.1201"); //$NON-NLS-1$
        Time date = TimestampWithTimezone.createTime(t);
       
        Calendar cal = Calendar.getInstance();
       
        cal.setTimeInMillis(date.getTime());
       
        assertEquals(cal.get(Calendar.HOUR_OF_DAY), 23);
        assertEquals(cal.get(Calendar.MINUTE), 39);
        assertEquals(cal.get(Calendar.SECOND), 10);
        assertEquals(cal.get(Calendar.MILLISECOND), 0);
        assertEquals(cal.get(Calendar.YEAR), 1970);
        assertEquals(cal.get(Calendar.MONTH), Calendar.JANUARY);
        assertEquals(cal.get(Calendar.DATE), 1);
    }
View Full Code Here

   
    public void testDateToDateConversion1() {
      Date t = Date.valueOf("2004-06-30"); //$NON-NLS-1$
      Date converted = TimestampWithTimezone.createDate(t, TimeZone.getTimeZone("America/Chicago"), Calendar.getInstance(TimeZone.getTimeZone("GMT"))); //$NON-NLS-1$ //$NON-NLS-2$
     
      Calendar cal = Calendar.getInstance();
      cal.setTime(converted);
     
      assertEquals(0, cal.get(Calendar.MILLISECOND));
    }
View Full Code Here

    /**
     * Tests date/time formatting in PDFObject.
     * @throws Exception if an error occurs
     */
    public void testDateFormatting() throws Exception {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
        cal.set(2008, Calendar.FEBRUARY, 07, 15, 11, 07);
        cal.set(Calendar.MILLISECOND, 0);
        Date dt = cal.getTime();

        MyPDFObject obj = new MyPDFObject();
        String s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT"));
        assertEquals("D:20080207151107Z", s);
        s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT+02:00"));
View Full Code Here

          activityForm.setActivityDetail(detaildetail);
        }

        // startdate
        String activitystartdate = requestForm.getStartDateTime();
        Calendar start = new GregorianCalendar(tz, locale);
        if (activitystartdate != null) {
          try {
            Date dd = simpleDateFormat.parse(activitystartdate);
            start.setTime(dd);
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
        }
        activityForm.setActivityStartDate(df.format(start.getTime()));
        activityForm.setActivityStartTime(tf.format(start.getTime()));

        String activityenddate = requestForm.getEndDateTime();
        Calendar end = new GregorianCalendar(tz, locale);
        if (activityenddate != null) {
          try {
            Date dd = simpleDateFormat.parse(activityenddate);
            end.setTime(dd);
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
        }
        activityForm.setActivityEndDate(df.format(end.getTime()));
        activityForm.setActivityEndTime(tf.format(end.getTime()));

        // alarm date time
        String alarmDateTime = requestForm.getAlarmDateTime();
        Calendar remind = new GregorianCalendar(tz, locale);
        // if alarmDateTime is not null , so set it to ActivityForm
        if (alarmDateTime != null) {
          try {
            Date d = simpleDateFormat.parse(alarmDateTime);
            remind.setTime(d);
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
        }
        activityForm.setActivityRemindDate(df.format(remind));
View Full Code Here

            m_loops = loops;
            m_random = new Random(5);
            m_halfRangeFraction = fraction * 0.5;
            m_halfRangeFractionRoot = Math.sqrt(fraction) * 0.5;
            m_utcZone = TimeZone.getTimeZone("UTC");
            Calendar calendar = new GregorianCalendar(m_utcZone);
            m_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            m_format.setCalendar(calendar);
            try {
                s_minDate = m_format.parse("2000-01-01 01:19:26").getTime();
                s_maxDate = m_format.parse("2003-08-31 23:07:59").getTime();
View Full Code Here

     */
    private void readQuakes(BufferedReader rdr)
        throws IOException, ParseException {
       
        // process actual quake listing input file
        Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        format.setCalendar(calendar);
        String line;
        while ((line = rdr.readLine()) != null) {
           
View Full Code Here

      CvFileFacade fileFacade = new CvFileFacade();
     
      CvFileVO fileVO = fileFacade.getFile(userId, fileId, dataSource);
      // set the form bean data from VO
      if (fileVO.getCompanyNews().equals("YES")) {
        Calendar fromcalendar =Calendar.getInstance();
        Calendar tocalendar = Calendar.getInstance();
        fromcalendar.setTime(fileVO.getFrom());
        tocalendar.setTime(fileVO.getTo());
       
        ((FileForm)form).setCompanynews("YES");
        ((FileForm)form).setStartday("" + fromcalendar.get(5));
        ((FileForm)form).setStartmonth("" + (fromcalendar.get(2) + 1));
        ((FileForm)form).setStartyear("" + fromcalendar.get(1));
        ((FileForm)form).setEndday("" + tocalendar.get(5));
        ((FileForm)form).setEndmonth("" + (tocalendar.get(2) + 1));
        ((FileForm)form).setEndyear("" + tocalendar.get(1));
      } else {
        ((FileForm)form).setCompanynews("NO");
        ((FileForm)form).setStartday("");
        ((FileForm)form).setStartmonth("");
        ((FileForm)form).setStartyear("");
View Full Code Here

TOP

Related Classes of java.util.Calendar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.