了解J2ME中RecordStore的同步需求(Understanding synchronization needs for RecordStore in J2ME)
阅读RecordStore文档 ,可以阅读以下内容:
Record store implementations ensure that all individual record store operations are atomic, synchronous, and serialized, so no corruption will occur with multiple accesses.
然后在下一句话:
However, if a MIDlet uses multiple threads to access a record store, it is the MIDlet's responsibility to coordinate this access or unintended consequences may result.
我不知道该怎么做。 操作是原子的和同步的,但我必须自己同步访问? 假设我不需要迭代记录,我需要为简单的添加/更新/删除功能提供什么类型的同步?
如果我需要迭代,如果我使用
RecordEnumeration
,enumerateRecords
方法是否拍摄RecordStore
的快照,还是直接连接到它?Reading up on the RecordStore documentation, one can read the following:
Record store implementations ensure that all individual record store operations are atomic, synchronous, and serialized, so no corruption will occur with multiple accesses.
and then at the very next sentence:
However, if a MIDlet uses multiple threads to access a record store, it is the MIDlet's responsibility to coordinate this access or unintended consequences may result.
I'm not sure what to make of this. The operations are atomic and synchronous but I have to synchronize access myself? Assuming I wouldn't need to iterate on the records, what type of synchronization do I need to have for simple add/update/delete functions?
And in case I do need iteration, if I use a
RecordEnumeration
, does theenumerateRecords
method take a snapshot of theRecordStore
, or is it directly connected to it?
原文:https://stackoverflow.com/questions/9008499
最满意答案
var dt = DateTime.ParseExact("2300H", @"HHmm\H", CultureInfo.InvariantCulture);
如果你需要时间
var time = dt.TimeOfDay;
var dt = DateTime.ParseExact("2300H", @"HHmm\H", CultureInfo.InvariantCulture);
if you need the time
var time = dt.TimeOfDay;
相关问答
更多-
var dt = DateTime.ParseExact("2300H", @"HHmm\H", CultureInfo.InvariantCulture); 如果你需要时间 var time = dt.TimeOfDay; var dt = DateTime.ParseExact("2300H", @"HHmm\H", CultureInfo.InvariantCulture); if you need the time var time = dt.TimeOfDay;
-
return fechaHora.Value.ToString("HH:mm"); You can get the desired result with the code below. Two'H' in HH is for 24-hour format. return fechaHora.Value.ToString("HH:mm");
-
使用扩展方法也是个好主意。 public static class MyExtensionClass { public static string ToFormat12h(this DateTime dt) { return dt.ToString("yyyy/MM/dd, hh:mm:ss tt"); } public static string ToFormat24h(this DateTime dt) { return dt.T ...
-
尝试使用SimpleDateFormat : String s = "12:18:00"; DateFormat f1 = new SimpleDateFormat("HH:mm:ss"); //HH for hour of the day (0 - 23) Date d = f1.parse(s); DateFormat f2 = new SimpleDateFormat("h:mma"); f2.format(d).toLowerCase(); // "12:18am" Try using a Sim ...
-
工作代码(考虑到您设法分割了字符串): public class App { public static void main(String[] args) { try { System.out.println(convertTo24HoursFormat("12:00AM")); // 00:00 System.out.println(convertTo24HoursFormat("12:00PM")); // 12:00 System.out.p ...
-
您可以使用以下命令来实现此目的: select from_unixtime(unix_timestamp(datetime,'MM/dd/yyyy hh:mm:ss aa'),'MM-dd-yyyy HH:mm:ss') from test_table; You can achieve this using below command: select from_unixtime(unix_timestamp(datetime,'MM/dd/yyyy hh:mm:ss aa'),'MM-dd-yyyy HH ...
-
如@Pascal所述,以strptime格式使用%H:%M:%S ,然后使用%I:%M:%S转换为12小时时间。 我们可以添加%p来表示'AM / PM' format(strptime(bc$time, format='%H:%M:%S'), '%I:%M:%S %p') #[1] "02:56:00 PM" "02:57:00 PM" "02:58:00 PM" "02:59:00 PM" "03:00:00 PM" #[6] "03:01:00 PM" 根据?strptime , %r可以代替%I: ...
-
尝试使用DateTimeParse和DateTimeKind.Utc进行转换 例: DateTime UniversalScheduleDate = DateTime.SpecifyKind( DateTime.Parse(txtDate.Text),DateTimeKind.Utc); string formattedDate = DateTime.UniversalScheduleDate.ToString("HH:mm:ss tt"); Try convert using the DateTime ...
-
您可以从字符串构造DateTime对象,如下所示: use DateTime::Format::Strptime qw( ); my $dt_format = DateTiFormat::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S', time_zone => 'local', on_error => 'croak', ); my $dt = $dt_format->parse_datetime('2015-02-23T16:59:2 ...
-
如果您知道字符串的格式,最好使用date_create_from_format函数 : $s = '01-31-2017 09:01 AM'; $date = date_create_from_format('m-d-Y h:i A', $s); var_dump($date->format('Y-m-d H:i:s')); 当你使用strtotime你让php解析字符串,这可能会导致你不想要的结果(例如 - 01-02-2017 - 是jan 2nd还是feb 1st?)。 If you know th ...