我想将字符串:"2012-04-20 10:10:00 + 0200"格式化为具有此格式的dateTime.所以我认为它必须是"yyyy-MM-dd:mm:ss zzz"?
当我试着这个
// starttime = {20/04/2012 10:10:00} without my +0200!
DateTime starttime = Convert.ToDateTime("2012-04-20 10:10:00+0200",CultureInfo.CurrentCulture);
// And this gave me a format exception : {System.FormatException: String was not recognized as a valid DateTime.
DateTime result = DateTime.ParseExact("2012-04-20 10:10:00+0200", "yyyy-MM-dd hh:mm:ss zzz", CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)
由"V4Vendetta"提供的解决方案:
您应该尝试使用DateTimeOffset而不是DateTime
DateTimeOffset result = DateTimeOffset.Parse("2012-04-20 10:10:00+0200",CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)
在这里你可以获得Offset(2小时),可以使用你的DateTime(10:10)值计算并得到你想要的输出(result.DateTime + result.Offset)
按下我想要的后退按钮时,无论加载什么屏幕,都会执行onCreate()方法.我想要这个,因为在浏览应用程序时屏幕必须刷新.
我是否需要覆盖后退按钮方法?
if(keyCode == KeyEvent.KEYCODE_BACK)
{
}
Run Code Online (Sandbox Code Playgroud) 这就是我在页面加载时看到我的屏幕的方式.但是当我开始滚动列表时,我的所有记录都开始变化,变得非常奇怪.我真的不知道为什么,有什么建议吗?

这是我ListView向上和向下滚动后的屏幕.

适配器:
private class TechnicalDocumentationAdapter extends
ArrayAdapter<TechnicalDocumentation> {
private ArrayList<TechnicalDocumentation> items;
public TechnicalDocumentationAdapter(Context context,
int textViewResourceId, ArrayList<TechnicalDocumentation> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.technicaldocumentationrow, null);
}
TechnicalDocumentation technicalDocumentation = items.get(position);
if (technicalDocumentation != null) {
TextView tt = (TextView) v.findViewById(R.id.TDRdate);
TextView bt = (TextView) v.findViewById(R.id.TDRobjectTypeCode);
TextView ct = …Run Code Online (Sandbox Code Playgroud)