// Copyright 2011 Google Inc. All Rights Reserved.

package com.google.appinventor.server.util;

import com.google.appengine.api.utils.SystemProperty;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Return timestamp information for when this server was last deployed
 *
 * @author sharon@google.com (Sharon Perl)
 *
 */
public class BuildData {

  private static long timestamp = 0;
  private static Date date = null;

  /**
   * Returns the timestamp for when the app was deployed (as a Unix time,
   * in milliseconds, suitable for passing to the java.util.Date() constructor
   *
   */
  public static long getTimestamp() {
    if (timestamp == 0) {
      // Note: the applicationVersion string has the format version.timestamp
      // The timestamp currently (when this was written) needs to be divided
      // by 2^28 to get it into unix epoch seconds. This could change according
      // to comments I found on the web, but there doesn't seem
      // to be any more stable API to get this info.
      String applicationVersion = SystemProperty.applicationVersion.get();
      if (applicationVersion != null) {
        String parts[] = applicationVersion.split("\\.");
        timestamp = (Long.parseLong(parts[1]) >> 28) * 1000;
        date = new Date(timestamp);
      }
    }
    return timestamp;
  }

  /**
   * Returns the timestamp for when the app was deployed, formatted as
   * a String suitable for displaying to the user in the default locale.
   * TODO(user): I'm not sure if this uses the user's locale, or the
   * server's. And which do we want?
   *
   */
  public static String getTimestampAsString() {
    if (timestamp == 0) {
      getTimestamp();
    }
    if (date != null) {
      return new SimpleDateFormat().format(date);
    }
    return "";
  }
}

@@ -1755,16 +1755,41 @@
 eFormat(
+%22EEE, d MMM yyyy HH:mm z%22
 ).format

Make small change to date/time format in build date