Package java.util

Examples of java.util.GregorianCalendar


     * @return LatLonPoint of the point on the earth that is closest.
     */
    public static LatLonPoint sunPosition(long mssue) {

        // Set the date and clock, based on the millisecond count:
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(new Date(mssue));

        double julianDate = calculateJulianDate(cal);

        // Need to correct time to GMT
        long gmtOffset = cal.get(Calendar.ZONE_OFFSET);
        // thanks to Erhard...
        long dstOffset = cal.get(Calendar.DST_OFFSET); // ins.
                                                       // 12.04.99
        cal.setTime(new Date(mssue - (gmtOffset + dstOffset))); // rep.
                                                                // 12.04.99

        double numDaysSinceEpoch = ((mssue / 1000) - EPOCH_TIME_SECS)
                / (24.0f * 3600.0f);

 
View Full Code Here


     * @return LatLonPoint of the point on the earth that is closest.
     */
    public static LatLonPoint moonPosition(long mssue) {

        // Set the date and clock, based on the millisecond count:
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(new Date(mssue));

        double julianDate = calculateJulianDate(cal);

        // Need to correct time to GMT
        long gmtOffset = cal.get(Calendar.ZONE_OFFSET);
        cal.setTime(new Date(mssue - gmtOffset));

        // Step 1,2
        double numDaysSinceEpoch = ((mssue / 1000) - EPOCH_TIME_SECS)
                / (24.0f * 3600.0f);
        // Step 3
View Full Code Here

   }
  
   @Transient
   public String getAge()
   {
      Calendar birthday = new GregorianCalendar();
      birthday.setTime(dob);
      int by = birthday.get(Calendar.YEAR);
      int bm = birthday.get(Calendar.MONTH);
      int bd = birthday.get(Calendar.DATE);
     
      Calendar now = new GregorianCalendar();
      now.setTimeInMillis(System.currentTimeMillis());
      int ny = now.get(Calendar.YEAR);
      int nm = now.get(Calendar.MONTH);
      int nd = now.get(Calendar.DATE);     
     
      int age = ny - by + (nm > bm || (nm == bm && nd >= bd) ? 0 : -1);                             
      return String.format("%d years old", age);                             
   }
View Full Code Here

  private void log(final long time,final Color foreground, final String text) {
    // syncExec - we need sequentially logging
    if (log_content.isDisposed()) return;
    SWTThread.getDisplay().syncExec(new Runnable() {
      public void run() {
        Calendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(time);
        int date_begin = log_content.getText().length();
        String date = TimeFormatter.twoDigits(calendar
            .get(Calendar.DAY_OF_MONTH))
            + "."
            + TimeFormatter
                .twoDigits(calendar.get(Calendar.MONTH) + 1)
            + "."
            + TimeFormatter.twoDigits(calendar.get(Calendar.YEAR));
        date += " "
            + TimeFormatter.twoDigits(calendar
                .get(Calendar.HOUR_OF_DAY))
            + ":"
            + TimeFormatter
                .twoDigits(calendar.get(Calendar.MINUTE))
            + ":"
            + TimeFormatter
                .twoDigits(calendar.get(Calendar.SECOND));
        date = "[" + date + "]";
        log_content.append(date);
               
        StyleRange date_style = new StyleRange();
        date_style.start = date_begin;
View Full Code Here

    } else {
      download_new_version_label.setText("No new version available");
    }
    long check_time = jmule_updater.getLastUpdateTime();
    if (check_time != 0) {
      Calendar calendar = new GregorianCalendar();
      calendar.setTimeInMillis(check_time);
      String upate_date = format(calendar.get(Calendar.DAY_OF_MONTH)) + "." +format(calendar.get(Calendar.MONTH) + 1) +"."+ format(calendar.get(Calendar.YEAR));
      upate_date += "  "+format(calendar.get(Calendar.HOUR_OF_DAY)) + ":"+format(calendar.get(Calendar.MINUTE))+":"+format(calendar.get(Calendar.SECOND));
      last_update_value.setText(upate_date);
    }
  }
View Full Code Here

    scroll_panel.setViewportView(text_area);
    this.add(scroll_panel);
  }
 
  public void addMessage(String str) {
    Calendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(System.currentTimeMillis());
    String date = TimeFormatter.twoDigits(calendar.get(Calendar.DAY_OF_MONTH)) + "." + TimeFormatter.twoDigits(calendar.get(Calendar.MONTH)) + "." + TimeFormatter.twoDigits(calendar.get(Calendar.YEAR));
    date += " "+TimeFormatter.twoDigits(calendar.get(Calendar.HOUR_OF_DAY)) + ":" + TimeFormatter.twoDigits(calendar.get(Calendar.MINUTE))+":"+TimeFormatter.twoDigits(calendar.get(Calendar.SECOND));
    date = "[" + date + "]";
    text_area.append(" " + date + " " + str + "\n");
  }
View Full Code Here

        fail("Expected failure to match " + Util.quote(aExpectedFailure) + ", but computed " + Util.quote(formattedDate));
      }
    }
   
    private Date getDate(int aYear, int aMonth, int aDay, int aHour, int aMinute){
      Calendar calendar = new GregorianCalendar(aYear, aMonth - 1, aDay, aHour, aMinute);
      return calendar.getTime();
    }
View Full Code Here

        LOG.log(Level.FINE, "server sending reply: ", reply);

        long timeToLive = 0;
        if (request.getJMSExpiration() > 0) {
            TimeZone tz = new SimpleTimeZone(0, "GMT");
            Calendar cal = new GregorianCalendar(tz);
            timeToLive =  request.getJMSExpiration() - cal.getTimeInMillis();
        }
       
        if (timeToLive >= 0) {
            ttl = ttl > 0 ? ttl : timeToLive;
            sender.send(replyTo, reply, deliveryMode, priority, ttl);
View Full Code Here

      displayTimeZone = TimeZone.getTimeZone(defaultDisplayTimeZone);
    else
      displayTimeZone= timeZone;
   
    setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5));
    GregorianCalendar date = new GregorianCalendar();
    date.setTimeZone(displayTimeZone);
    date.setTimeInMillis(new Double(value).longValue());

    add(_dayField = new DatePartField(date.get(Calendar.DAY_OF_MONTH), date.getActualMinimum(Calendar.DAY_OF_MONTH), date.getActualMaximum(Calendar.DAY_OF_MONTH), 2));
    String[] months = new String[12];
    SimpleDateFormat dateFmt = new SimpleDateFormat("MMM");
    boolean isComplete = false;
    for(GregorianCalendar iDate = new GregorianCalendar(1970, Calendar.JANUARY, 1);
    !isComplete ;
    iDate.roll(Calendar.MONTH, true)) {
      months[iDate.get(Calendar.MONTH)] = dateFmt.format(new Date(iDate.getTimeInMillis()));
      isComplete = iDate.get(Calendar.MONTH) == Calendar.DECEMBER;
    }
    _monthField = new JComboBox(months);
    add(_monthField);
    _monthField.setSelectedIndex(date.get(Calendar.MONTH));
    add(_yearField = new NumberField(date.get(Calendar.YEAR), 4));
View Full Code Here

    Date dateTmp = getDate();
    return dateTmp.getTime();
  }

  public void setValue(double value) {
    GregorianCalendar date = new GregorianCalendar();
    date.setTimeZone(displayTimeZone);
    date.setTimeInMillis(new Double(value).longValue());

    _dayField.setValue(date.get(Calendar.DAY_OF_MONTH));
    _monthField.setSelectedIndex(date.get(Calendar.MONTH));
    _yearField.setValue(date.get(Calendar.YEAR));
    _hourField.setValue(date.get(Calendar.HOUR_OF_DAY));
    _minuteField.setValue(date.get(Calendar.MINUTE));
    _secondField.setValue(date.get(Calendar.SECOND));
    _millisecondField.setValue(date.get(Calendar.MILLISECOND));
  }
View Full Code Here

TOP

Related Classes of java.util.GregorianCalendar

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.