private TimeUtilities() {
   TIME_FORMATTER_SQLITE_UTC.setTimeZone(TimeZone.getTimeZone("UTC"));
   TIME_FORMATTER_GPX_UTC.setTimeZone(TimeZone.getTimeZone("UTC"));
   TIME_FORMATTER_UTC.setTimeZone(TimeZone.getTimeZone("UTC"));
   TIMESTAMPFORMATTER_UTC.setTimeZone(TimeZone.getTimeZone("UTC"));
   EXIFFORMATTER.setTimeZone(TimeZone.getTimeZone("UTC"));
 }
Exemplo n.º 2
0
  /**
   * email下发的时间转换成UTC时间
   *
   * @author 李颖00124251
   * @version [RCS Client V100R001C03, 2012-3-16]
   * @param dateStr String email下发的字符串
   * @return String 经过解析后的utc时间
   * @exception ParseException 解析错误
   */
  public static String changeEmailTimeToUtc(String dateStr) throws ParseException {
    if (null == dateStr || dateStr.length() < "yyyy-MM-ddTHH:mm:ss".length()) {
      return dateStr;
    }

    String time = dateStr.substring(0, "yyyy-MM-ddTHH:mm:ss".length());
    String zoneStr = dateStr.substring("yyyy-MM-ddTHH:mm:ss".length());

    TimeZone emailTimeZone = TimeZone.getTimeZone("GMT+0");

    if (zoneStr != null && (zoneStr.contains("+") || zoneStr.contains("-"))) {

      emailTimeZone = TimeZone.getTimeZone("GMT" + zoneStr);
    } else {
      emailTimeZone = TimeZone.getTimeZone("GMT+0");
    }

    SimpleDateFormat localFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    localFormatter.setTimeZone(emailTimeZone);
    // 获取本地时间
    Date localDate = localFormatter.parse(time);

    // 设置存储时区为utc时区
    localFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0"));

    return localFormatter.format(localDate);
  }
Exemplo n.º 3
0
  public static String getDate(Context context, String date, String toTimezone, String format) {

    if (date.equals("false")) {
      return date;
    }

    Calendar cal = Calendar.getInstance();
    Date originalDate = convertToDate(date);
    cal.setTime(originalDate);

    Date oDate = removeTime(originalDate);
    Date today = removeTime(currentDate());
    String finalDateTime = "";
    if (format == null) {
      dateFormat = new SimpleDateFormat(dateFormat(context));
      timeFormat = new SimpleDateFormat(timeFormat(context));
      dateFormat.setTimeZone(TimeZone.getTimeZone(toTimezone));
      timeFormat.setTimeZone(TimeZone.getTimeZone(toTimezone));
      if (today.compareTo(oDate) < 0) {
        // sending date
        finalDateTime = dateFormat.format(oDate);
      } else {
        // sending time because it's today.
        finalDateTime = timeFormat.format(convertToTimezone(cal, toTimezone).getTime());
      }
    } else {
      dateFormat = new SimpleDateFormat(format);
      dateFormat.setTimeZone(TimeZone.getTimeZone(toTimezone));
      finalDateTime = dateFormat.format(convertFullToTimezone(cal, toTimezone).getTime());
    }

    return finalDateTime;
  }
Exemplo n.º 4
0
 public AccessDateStruct() {
   TimeZone tz = TimeZone.getDefault();
   dayFormatter.setTimeZone(tz);
   monthFormatter.setTimeZone(tz);
   yearFormatter.setTimeZone(tz);
   timeFormatter.setTimeZone(tz);
 }
  public static String convertLocalTimeToUTC(String cityName, String localDateTimeString) {
    String result = ""; // Will hold the final converted date
    Date localDate = null;
    // String localTimezoneId = "";
    SimpleDateFormat lv_formatter;
    SimpleDateFormat lv_parser;

    String localTimezoneId = chooseTimezoneIdByCityName(cityName);

    // create a new Date object using the timezone of the specified city
    lv_parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    lv_parser.setTimeZone(TimeZone.getTimeZone(localTimezoneId));
    try {
      localDate = lv_parser.parse(localDateTimeString);
    } catch (ParseException e) {
      return null;
    }

    // Set output format prints "2007/10/25  18:35:07 EDT(-0400)"
    lv_formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z'('Z')'");
    lv_formatter.setTimeZone(TimeZone.getTimeZone(localTimezoneId));

    // System.out.println("convertLocalTimeToUTC: " + p_city + ": " + " The Date in the local time
    // zone "
    // + lv_formatter.format(localDate));

    // Convert the date from the local timezone to UTC timezone
    lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    result = lv_formatter.format(localDate);
    // System.out.println("convertLocalTimeToUTC: " + cityName + ": " + " The Date in the UTC time
    // zone " + result);

    return result;
  }
Exemplo n.º 6
0
 /**
  * Parses the comment lines for harbor info and time zone.
  *
  * @param line
  */
 private void processComment(String line) {
   if (asReadTheHarborInfo && asReadTheTimeZoneInfo) return;
   if (isCommentLine(line)) {
     if (!asReadTheHarborInfo) {
       String val = extractValueWithHeader(line, TidWriter.HARBOR_STR);
       if (val != null && !val.isEmpty()) {
         harbor = val;
         asReadTheHarborInfo = true;
         return;
       }
     }
     if (!asReadTheTimeZoneInfo) {
       String val = extractValueWithHeader(line, TidWriter.TIMEZONE_STR);
       if (val != null && !val.isEmpty()) {
         TimeZone tz = TimeZone.getTimeZone(val);
         if (tz.getID().equalsIgnoreCase(val)) {
           dateTimeFormatterUTC.setTimeZone(tz);
           dateTimeFormatterUTC2.setTimeZone(tz);
         } else {
           NeptusLog.pub().error("Error processing time zone, using UTC.");
         }
         asReadTheTimeZoneInfo = true;
         return;
       }
     }
   }
 }
Exemplo n.º 7
0
  @AfterViews
  public void setPreferences() {

    SharedPreferences preferences =
        getActivity().getSharedPreferences("CurrentUser", Context.MODE_PRIVATE);

    accessToken = preferences.getString("access_token", "").replace("\"", "");
    if (getArguments() != null) {
      Todo todo = (Todo) getArguments().getSerializable(NEW_INSTANCE_TODO_KEY);
      concernedMembers.addAll(todo.members);
      currentTodoId = todo.id;
      todoInput.setText(todo.text);
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      format.setTimeZone(TimeZone.getTimeZone("UTC"));
      Date date = new Date();
      try {
        date = format.parse(todo.remindMeAt);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      Calendar cal = Calendar.getInstance();
      TimeZone tz = cal.getTimeZone();
      SimpleDateFormat formatToShow = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      formatToShow.setTimeZone(tz);

      String[] splitDate = formatToShow.format(date).split(" ");
      dateText.setText(splitDate[0]);
      timeText.setText(splitDate[1]);
    }
  }
 static {
   TimeZone tz = TimeZone.getTimeZone("UTC");
   isoDateFormatter.setTimeZone(tz);
   gs1Format.setTimeZone(tz);
   simpleFormat.setTimeZone(tz);
   simpleTimeFormat.setTimeZone(tz);
 }
Exemplo n.º 9
0
  @SuppressWarnings("deprecation")
  private String getDisplayTime(String datetime) {

    try {
      SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      sourceFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
      Date parsed = sourceFormat.parse(datetime); // => Date is in UTC now

      TimeZone tz = TimeZone.getDefault();
      SimpleDateFormat destFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      destFormat.setTimeZone(tz);

      String result = destFormat.format(parsed);

      Date dt = sdf.parse(result);
      if (now.getYear() == dt.getYear()
          && now.getMonth() == dt.getMonth()
          && now.getDate() == dt.getDate()) {
        return tformat.format(dt);
      }
      return dformat.format(dt);
    } catch (Exception e) {
    }
    return "";
  }
Exemplo n.º 10
0
 public TMXReader2() {
   factory = XMLInputFactory.newInstance();
   factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
   factory.setXMLReporter(
       new XMLReporter() {
         public void report(String message, String error_type, Object info, Location location)
             throws XMLStreamException {
           Log.logWarningRB(
               "TMXR_WARNING_WHILE_PARSING",
               new Object[] {
                 String.valueOf(location.getLineNumber()),
                 String.valueOf(location.getColumnNumber())
               });
           Log.log(message + ": " + info);
           warningsCount++;
         }
       });
   factory.setXMLResolver(TMX_DTD_RESOLVER_2);
   dateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.ENGLISH);
   dateFormat1.setTimeZone(TimeZone.getTimeZone("UTC"));
   dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
   dateFormat2.setTimeZone(TimeZone.getTimeZone("UTC"));
   dateFormatOut = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.ENGLISH);
   dateFormatOut.setTimeZone(TimeZone.getTimeZone("UTC"));
 }
Exemplo n.º 11
0
 static {
   for (SimpleDateFormat format : DATE_FORMATS) {
     format.setLenient(true);
     format.setTimeZone(UTC_TIMEZONE);
   }
   NO_YEAR_DATE_FORMAT.setTimeZone(UTC_TIMEZONE);
   FORMAT_WITHOUT_YEAR_MONTH_FIRST.setTimeZone(UTC_TIMEZONE);
   FORMAT_WITHOUT_YEAR_DATE_FIRST.setTimeZone(UTC_TIMEZONE);
 }
Exemplo n.º 12
0
  static {
    dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    dateTimeFormatMillis = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    dateTimeFormatMillis.setTimeZone(TimeZone.getTimeZone("UTC"));
  }
Exemplo n.º 13
0
  public TimelineAdapter() {
    dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
    dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
    dateSeparatorFormat = new SimpleDateFormat("yyyy/MM/dd");
    dateSeparatorFormat.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));

    cells.add(new DateSeparatorCell(new Date()));

    formCell = new PostingCell();
    cells.add(formCell);
  }
Exemplo n.º 14
0
 public String convertToString(Object value, Locale locale) {
   SimpleDateFormat dateFmt = new SimpleDateFormat(fmt);
   if (value instanceof Calendar) {
     Calendar cal = (Calendar) value;
     dateFmt.setTimeZone(cal.getTimeZone());
     return dateFmt.format(cal.getTime());
   }
   if (value instanceof Date) {
     dateFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
     return dateFmt.format((Date) value);
   }
   return null;
 }
Exemplo n.º 15
0
  public MissingPlotPanel(Connection dbConn) {
    // version 0.0.10
    dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT+10"));
    dateParser.setTimeZone(TimeZone.getTimeZone("GMT+10"));
    this.dbConn = dbConn;

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            buildGUI();
          }
        });
  }
Exemplo n.º 16
0
  public static void main(String args[]) {

    TimeZone.setDefault(TimeZone.getTimeZone("America/Bogota"));

    DateTime dt = new DateTime();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    //		System.out.println("- " + sdf.format(dt.toDate()));
    //		sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
    //		System.out.println("- " + sdf.format(dt.toDate()));

    String sd = "2011-03-18 16:30:39";
    sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
    Date d = null;
    try {
      d = sdf.parse(sd);
    } catch (ParseException e) {
      e.printStackTrace();
    }
    System.out.println("- " + sdf.format(d));
    sdf.setTimeZone(TimeZone.getTimeZone("America/Bogota"));
    System.out.println("- " + sdf.format(d));

    try {
      d = sdf.parse(sd);
    } catch (ParseException e) {
      e.printStackTrace();
    }
    System.out.println("- " + sdf.format(d));

    DateTime nDt = dt.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Asia/Shanghai")));
    System.out.println(sdf.format(nDt.toDate()));

    DateTime dt2 = new DateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Asia/Tokyo")));

    sdf.setTimeZone(TimeZone.getTimeZone("America/Bogota"));
    System.out.println(sdf.format(dt2.toDate()));

    //		System.out.println(getFormatedDateString(""));
    //		System.out.println(getFormatedDateString("America/Bogota"));
    //
    //		//printSysProperties();
    //
    //		System.out.println("------------------------------------------");
    ////		System.setProperty("user.timezone", "America/Bogota");
    //		TimeZone.setDefault(TimeZone.getTimeZone("America/Bogota"));
    //
    //		System.out.println(getFormatedDateString(""));
    //		System.out.println(getFormatedDateString("Asia/Shanghai"));

    // printSysProperties();
  }
Exemplo n.º 17
0
  /**
   * Creates the Hadoop authentication HTTP cookie.
   *
   * @param token authentication token for the cookie.
   * @param expires UNIX timestamp that indicates the expire date of the cookie. It has no effect if
   *     its value < 0.
   *     <p>XXX the following code duplicate some logic in Jetty / Servlet API, because of the fact
   *     that Hadoop is stuck at servlet 2.5 and jetty 6 right now.
   */
  public static void createAuthCookie(
      HttpServletResponse resp,
      String token,
      String domain,
      String path,
      long expires,
      boolean isSecure) {
    StringBuilder sb = new StringBuilder(AuthenticatedURL.AUTH_COOKIE).append("=");
    if (token != null && token.length() > 0) {
      sb.append("\"").append(token).append("\"");
    }
    sb.append("; Version=1");

    if (path != null) {
      sb.append("; Path=").append(path);
    }

    if (domain != null) {
      sb.append("; Domain=").append(domain);
    }

    if (expires >= 0) {
      Date date = new Date(expires);
      SimpleDateFormat df = new SimpleDateFormat("EEE, " + "dd-MMM-yyyy HH:mm:ss zzz");
      df.setTimeZone(TimeZone.getTimeZone("GMT"));
      sb.append("; Expires=").append(df.format(date));
    }

    if (isSecure) {
      sb.append("; Secure");
    }

    sb.append("; HttpOnly");
    resp.addHeader("Set-Cookie", sb.toString());
  }
    public ImportImageBuilder withBucketUploadPolicy(final String bucket, final String prefix) {
      try {
        final AccessKey adminAccessKey = Accounts.lookupSystemAdmin().getKeys().get(0);
        this.importDisk.setAccessKey(adminAccessKey.getAccessKey());
        final Calendar c = Calendar.getInstance();
        c.add(Calendar.HOUR, 48); // IMPORT_TASK_EXPIRATION_HOURS=48
        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        final String expiration = sdf.format(c.getTime());
        // based on
        // http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-BundleInstance.html
        final String policy =
            String.format(
                "{\"expiration\":\"%s\",\"conditions\":[{\"bucket\": \"%s\"},"
                    + "[\"starts-with\", \"$key\", \"%s\"],{\"acl\":\"aws-exec-read\"}]}",
                expiration, bucket, prefix);
        this.importDisk.setUploadPolicy(B64.standard.encString(policy));

        final Mac hmac = Mac.getInstance("HmacSHA1");
        hmac.init(new SecretKeySpec(adminAccessKey.getSecretKey().getBytes("UTF-8"), "HmacSHA1"));

        this.importDisk.setUploadPolicySignature(
            B64.standard.encString(hmac.doFinal(B64.standard.encString(policy).getBytes("UTF-8"))));
      } catch (final Exception ex) {
        throw Exceptions.toUndeclared(ex);
      }
      return this;
    }
Exemplo n.º 19
0
  /**
   * converts this GDay into a local java Date.
   *
   * @return a local date representing this Date.
   */
  public java.util.Date toDate() {

    java.util.Date date = null;
    SimpleDateFormat df = new SimpleDateFormat(DAY_FORMAT);
    // Set the time zone
    if (isUTC()) {
      SimpleTimeZone timeZone = new SimpleTimeZone(0, "UTC");
      int offset = 0;
      offset = (int) ((this.getZoneMinute() + this.getZoneHour() * 60) * 60 * 1000);
      offset = isZoneNegative() ? -offset : offset;
      timeZone.setRawOffset(offset);
      timeZone.setID(timeZone.getAvailableIDs(offset)[0]);
      df.setTimeZone(timeZone);
    }

    try {
      date = df.parse(this.toString());
    } catch (ParseException e) {
      // this can't happen since toString() should return the proper
      // string format
      e.printStackTrace();
      return null;
    }
    return date;
  } // toDate()
Exemplo n.º 20
0
  /**
   * Creates and returns the content of the information area.
   *
   * @param composite The parent composite to contain the information area
   */
  private Composite createInfoArea(Composite composite) {
    Group group = new Group(composite, SWT.CENTER);
    group.setText("Info");
    GridLayout layout = new GridLayout(2, false);
    group.setLayout(layout);

    Label dateLabel = new Label(group, SWT.LEFT);
    dateLabel.setText("Date");
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    dateLabel.setLayoutData(gd);
    dateText = new Text(group, SWT.SINGLE | SWT.BORDER);
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    final TimeZone local = TimeZone.getDefault();
    sdf.setTimeZone(local);
    // new Date() gets current date/elapsedTime
    final String dateString = sdf.format(new Date());
    dateText.setText(dateString);
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    dateText.setLayoutData(gd);

    Label authorLabel = new Label(group, SWT.LEFT);
    authorLabel.setText("Author");
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    authorLabel.setLayoutData(gd);
    authorText = new Text(group, SWT.SINGLE | SWT.BORDER);
    // should look in preferences...
    authorText.setText(
        Activator.getDefault()
            .getPreferenceStore()
            .getString(ProfileDefinitionPreferenceConstants.PREF_AUTHOR_NAME));
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    authorText.setLayoutData(gd);

    return group;
  }
  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    try {
      loadFile();
      mAdapter.clear();
      for (int i = mFav.length() - 1; i >= 0; i--) {
        long dt = mFav.getJSONObject(i).getJSONObject("datetime").getLong("$date");
        Date datetime = new Date(dt);
        sdf1.setTimeZone(TimeZone.getTimeZone("GMT"));
        String crawlTime = sdf1.format(datetime);
        // String time = getTime(crawlTime);

        mAdapter.add(
            new String[] {
              mFav.getJSONObject(i).getString("from")
                  + " -> "
                  + mFav.getJSONObject(i).getString("to"),
              crawlTime
            });
        // +DateFormat.getDateFormat(GoodResultActivity.this).format(new
        // Date(jArray.getJSONObject(i).getLong("$date"))));
      }
      mAdapter.notifyDataSetChanged();
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemplo n.º 22
0
 public static String convertDate(long unixTime) {
   SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
   Calendar cal = Calendar.getInstance();
   cal.setTimeInMillis(unixTime * 1000);
   sdf.setTimeZone(cal.getTimeZone());
   return sdf.format(cal.getTime());
 }
Exemplo n.º 23
0
 public static String format(long milliseconds, String format) {
   SimpleDateFormat sdf = new SimpleDateFormat(format);
   sdf.setTimeZone(CURRENT_TIME_ZONE);
   Date t = new Date();
   t.setTime(milliseconds);
   return sdf.format(t);
 }
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    UserService userService = UserServiceFactory.getUserService();
    if (userService.isUserLoggedIn()) {
      User user = userService.getCurrentUser();
      out.println("<p>You are signed in as " + user.getNickname() + ". ");
      if (userService.isUserAdmin()) {
        out.println("You are an administrator. ");
      }
      out.println("<a href=\"" + userService.createLogoutURL("/") + "\">Sign out</a>.</p>");
    } else {
      out.println(
          "<p>You are not signed in to Google Accounts. "
              + "<a href=\""
              + userService.createLoginURL(req.getRequestURI())
              + "\">Sign in</a>.</p>");
    }

    out.println(
        "<ul>"
            + "<li><a href=\"/\">/</a></li>"
            + "<li><a href=\"/required\">/required</a></li>"
            + "<li><a href=\"/admin\">/admin</a></li>"
            + "</ul>");

    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSSSS");
    fmt.setTimeZone(new SimpleTimeZone(0, ""));
    out.println("<p>The time is: " + fmt.format(new Date()) + "</p>");
  }
Exemplo n.º 25
0
 /**
  * 把int类型的毫秒数转换成时间格式
  *
  * @param milliscond
  * @return
  */
 public static String milliscond2Time(int milliscond) {
   Date date = new Date();
   SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
   sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
   date.setTime(milliscond);
   return sdf.format(date);
 }
  public void run() {
    log.info("InvalidateDaemon started");

    sdb = AdWhirlUtil.getSDB();

    // We're a makeshift daemon, let's loop forever
    while (true) {

      Date date = new Date();
      Calendar c = new GregorianCalendar();
      c.setTime(date);
      c.add(Calendar.SECOND, -60);
      date = c.getTime();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd, HH:mm:ss");
      sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
      String dateTime = sdf.format(date);

      log.info("Cutoff is: " + dateTime);

      invalidateApps(dateTime);
      invalidateCustoms(dateTime);

      try {
        Thread.sleep(30000);
      } catch (InterruptedException e) {
        log.error("Unable to sleep... continuing");
      }
    }
  }
  /**
   * Sets the Date header for the HTTP response
   *
   * @param response HTTP response
   */
  private static void setDateHeader(FullHttpResponse response) {
    SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
    dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));

    Calendar time = new GregorianCalendar();
    response.headers().set(DATE, dateFormatter.format(time.getTime()));
  }
  @SuppressWarnings("unused")
  // called by reflection
  private List<String> testLeftJoinCube2() throws Exception {
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
    f.setTimeZone(TimeZone.getTimeZone("GMT"));
    List<String> result = Lists.newArrayList();
    final String cubeName = "test_kylin_cube_without_slr_left_join_empty";
    // this cube's start date is 0, end date is 20120601000000
    long dateStart =
        cubeManager
            .getCube(cubeName)
            .getDescriptor()
            .getModel()
            .getPartitionDesc()
            .getPartitionDateStart();
    long dateEnd = f.parse("2012-06-01").getTime();

    clearSegment(cubeName);
    result.add(buildSegment(cubeName, dateStart, dateEnd));

    // then submit an append job, start date is 20120601000000, end
    // date is 20220101000000
    dateStart = f.parse("2012-06-01").getTime();
    dateEnd = f.parse("2022-01-01").getTime();
    result.add(buildSegment(cubeName, dateStart, dateEnd));
    return result;
  }
Exemplo n.º 29
0
 public static String millisecondsToHumanDateWithSeconds(long milliseconds) {
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   sdf.setTimeZone(CURRENT_TIME_ZONE);
   Date t = new Date();
   t.setTime(milliseconds);
   return sdf.format(t);
 }
Exemplo n.º 30
0
  /** base constructer from a java.util.date object */
  public DERGeneralizedTime(Date time) {
    SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss'Z'");

    dateF.setTimeZone(new SimpleTimeZone(0, "Z"));

    this.time = dateF.format(time);
  }