示例#1
0
    List<String> calc(String str_date) {
      long myDateMillis = 0;
      long d1900 = 0;
      Date myDate = null;
      List<String> ls = new ArrayList<String>();
      try {

        myDate = parseDate(str_date);
        System.out.println(printDate(myDate) + " // orig date");
        //
        Calendar cal = Calendar.getInstance();

        cal.setTime(myDate);
        cal.add(Calendar.HOUR, -5);
        cal.add(Calendar.MINUTE, -30);
        myDate = cal.getTime(); // Update date to -5:30
        //
        Calendar c = Calendar.getInstance();
        c.clear();
        c.setTimeZone(TimeZone.getTimeZone("GMT"));
        c.set(1900, 0, 1, 0, 0, 0);
        d1900 = c.getTimeInMillis();
        System.out.println(printDate(c.getTime()) + " // 1900");

        for (int i = 0; i < 10; i++) {
          long durInSec = (cal.getTimeInMillis() - d1900) / 1000;
          String durInSecHex = Long.toHexString(durInSec);
          System.out.println(printDate(cal.getTime()) + " " + durInSec + " " + durInSecHex);
          ls.add(durInSecHex);
          cal.add(Calendar.SECOND, +50);
        }

      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return ls;
    } // DateCalc constructor
示例#2
0
 public Date parseDate(String s) throws ParseException {
   DateFormat sdf;
   sdf = new SimpleDateFormat("yyyyyy/MM/dd HH:mm:ss Z");
   sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
   return (Date) sdf.parse(s);
 }
示例#3
0
    public String printDate(Date d) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss Z");
      sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

      return sdf.format(d);
    }