我似乎无法让gson在Java中将Date转换为UTC时间....这是我的代码......
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
//This is the format I want, which according to the ISO8601 standard - Z specifies UTC - 'Zulu' time
Date now=new Date();
System.out.println(now);
System.out.println(now.getTimezoneOffset());
System.out.println(gson.toJson(now));
Run Code Online (Sandbox Code Playgroud)
这是我的输出
Thu Sep 25 18:21:42 BST 2014 // Time now - in British Summer Time
-60 // As expected : offset is 1hour from UTC
"2014-09-25T18:21:42.026Z" // Uhhhh this is not UTC ??? Its still BST !!
Run Code Online (Sandbox Code Playgroud)
我想要的gson结果和我期待的结果
"2014-09-25T17:21:42.026Z"
Run Code Online (Sandbox Code Playgroud)
我可以清楚地在调用Json之前减去1小时,但这似乎是一个黑客.如何配置gson始终转换为UTC?
我希望能够在TrueType字体文件中提取每个字母的几何.每个字母都有一组坐标,假设每个字母都在自己的网格中.
正如一张图片说的千言万语 - 我想得到类似于下图的字母顶点(http://polymaps.org/提供)
更新
由于提示使用GDI,现在已经将其集成到.NET System.Drawing.Drawing2D中,我获得了以下代码来创建WKT多边形.没有贝塞尔曲线可能.即使在翻转和旋转字母后,某些路径仍然无法正确连接.
// C# Visual Studio
GraphicsPath gp = new GraphicsPath();
Point origin = new Point(0, 0);
StringFormat format = new StringFormat();
FontFamily ff = new FontFamily("Arial");
//enter letter here
gp.AddString("T", ff, 0, 12, origin, format); //ABCDEFGHIJKLMNOPQRSTUVWXYZ
StringBuilder sb = new StringBuilder();
sb.AppendLine("DECLARE @g geometry;");
sb.Append("SET @g = geometry::STGeomFromText('POLYGON ((");
Matrix flipmatrix = new Matrix(-1, 0, 0, 1, 0, 0);
gp.Transform(flipmatrix);
Matrix rotationtransform = new Matrix();
RectangleF r = gp.GetBounds();
// Get center …
Run Code Online (Sandbox Code Playgroud)