public Stat() { { timeFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); timeFmt.SetTimeZone(Extensions.GetTimeZone("UTC")); } }
public static SimpleDateFormat GetDateFormat() { SimpleDateFormat df = new SimpleDateFormat(HftpDateFormat); df.SetTimeZone(Sharpen.Extensions.GetTimeZone(HftpTimezone)); return(df); }
/// <summary>Creates the Hadoop authentication HTTP cookie.</summary> /// <param name="token">authentication token for the cookie.</param> /// <param name="expires"> /// UNIX timestamp that indicates the expire date of the /// cookie. It has no effect if its value < 0. /// 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. /// </param> public static void CreateAuthCookie(HttpServletResponse resp, string token, string domain, string path, long expires, bool isSecure) { StringBuilder sb = new StringBuilder(AuthenticatedURL.AuthCookie).Append("="); if (token != null && token.Length > 0) { sb.Append("\"").Append(token).Append("\""); } if (path != null) { sb.Append("; Path=").Append(path); } if (domain != null) { sb.Append("; Domain=").Append(domain); } if (expires >= 0) { DateTime date = Extensions.CreateDate(expires); SimpleDateFormat df = new SimpleDateFormat("EEE, " + "dd-MMM-yyyy HH:mm:ss zzz"); df.SetTimeZone(Extensions.GetTimeZone("GMT")); sb.Append("; Expires=").Append(df.Format(date)); } if (isSecure) { sb.Append("; Secure"); } sb.Append("; HttpOnly"); resp.AddHeader("Set-Cookie", sb.ToString()); }
private string Iso(PersonIdent id) { SimpleDateFormat fmt; fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); fmt.SetTimeZone(id.GetTimeZone()); return(fmt.Format(id.GetWhen())); }
private static string HttpNow() { string tz = "GMT"; SimpleDateFormat fmt; fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture ); fmt.SetTimeZone(Sharpen.Extensions.GetTimeZone(tz)); return(fmt.Format(new DateTime()) + " " + tz); }
public override string ToString() { StringBuilder r = new StringBuilder(); SimpleDateFormat dtfmt; dtfmt = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy Z", CultureInfo.InvariantCulture ); dtfmt.SetTimeZone(GetTimeZone()); r.Append("PersonIdent["); r.Append(GetName()); r.Append(", "); r.Append(GetEmailAddress()); r.Append(", "); r.Append(dtfmt.Format(Sharpen.Extensions.ValueOf(when))); r.Append("]"); return(r.ToString()); }
/// <summary> /// creates a /// <see cref="Sharpen.SimpleDateFormat">Sharpen.SimpleDateFormat</see> /// for the requested format string. /// </summary> /// <param name="pattern"> /// a non-<code>null</code> format String according to /// <see cref="Sharpen.SimpleDateFormat">Sharpen.SimpleDateFormat</see> /// . The format is not checked against /// <code>null</code> since all paths go through /// <see cref="DateUtils">DateUtils</see> /// . /// </param> /// <returns> /// the requested format. This simple dateformat should not be used /// to /// <see cref="Sharpen.SimpleDateFormat.ApplyPattern(string)">apply</see> /// to a /// different pattern. /// </returns> public static SimpleDateFormat FormatFor(string pattern) { SoftReference <IDictionary <string, SimpleDateFormat> > @ref = ThreadlocalFormats.Get (); IDictionary <string, SimpleDateFormat> formats = @ref.Get(); if (formats == null) { formats = new Dictionary <string, SimpleDateFormat>(); ThreadlocalFormats.Set(new SoftReference <IDictionary <string, SimpleDateFormat> >(formats )); } SimpleDateFormat format = formats.Get(pattern); if (format == null) { format = new SimpleDateFormat(pattern, CultureInfo.InvariantCulture); format.SetTimeZone(Sharpen.Extensions.GetTimeZone("GMT")); formats.Put(pattern, format); } return(format); }
public virtual DateTime?GetDate(int tagType, [CanBeNull] TimeZoneInfo timeZone) { object o = GetObject(tagType); if (o == null) { return(null); } if (o is DateTime) { return((DateTime)o); } if (o is string) { // This seems to cover all known Exif date strings // Note that " : : : : " is a valid date string according to the Exif spec (which means 'unknown date'): http://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif/datetimeoriginal.html string[] datePatterns = new string[] { "yyyy:MM:dd HH:mm:ss", "yyyy:MM:dd HH:mm", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" }; string dateString = (string)o; foreach (string datePattern in datePatterns) { try { DateFormat parser = new SimpleDateFormat(datePattern); if (timeZone != null) { parser.SetTimeZone(timeZone); } return(parser.Parse(dateString)); } catch (ParseException) { } } } // simply try the next pattern return(null); }