0
A
回答
0
我不知道我完全理解你的問題。如果您想獲得當前日期,使用此代碼:
java.util.Date today = new java.util.Date();
獲得當前的日期,然後使用
today.toString()
獲得信息,如日,月,年。 (查看這個BlackBerry API)
如果你想設置一個日期對象,我可能會使用日曆。
這裏就是我創建一個基於指定日期的日曆對象我的代碼示例,然後將其添加到黑莓日曆
PIM pim = PIM.getInstance();
try {
String _date = date.getText();
int _month = Integer.parseInt(_date.substring(0, _date.indexOf('/')));
_date = _date.substring(_date.indexOf('/') + 1);
int _day = Integer.parseInt(_date.substring(0, _date.indexOf('/')));
_date = _date.substring(_date.indexOf('/') + 1);
int _year = Integer.parseInt(_date.substring(0, _date.indexOf('/')));
_year = _year + 2000;
EventList events = (EventList) pim.openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
Event event = events.createEvent();
event.addString(Event.SUMMARY, PIMItem.ATTR_NONE, title.getText());
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, _year);
//this of course seems like a terrible way to set the months, but the BlackBerry
//api wants the month in this format
if(_month == 1)
cal.set(Calendar.MONTH, Calendar.JANUARY);
if(_month == 2)
cal.set(Calendar.MONTH, Calendar.FEBRUARY);
if(_month == 3)
cal.set(Calendar.MONTH, Calendar.MARCH);
if(_month == 4)
cal.set(Calendar.MONTH, Calendar.APRIL);
if(_month == 5)
cal.set(Calendar.MONTH, Calendar.MAY);
if(_month == 6)
cal.set(Calendar.MONTH, Calendar.JUNE);
if(_month == 7)
cal.set(Calendar.MONTH, Calendar.JULY);
if(_month == 8)
cal.set(Calendar.MONTH, Calendar.AUGUST);
if(_month == 9)
cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
if(_month == 10)
cal.set(Calendar.MONTH, Calendar.OCTOBER);
if(_month == 11)
cal.set(Calendar.MONTH, Calendar.NOVEMBER);
if(_month == 12)
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DATE, _day);
cal.set(Calendar.HOUR_OF_DAY, 17);
cal.set(Calendar.MINUTE, 15);
event.addDate(Event.START, PIMItem.ATTR_NONE, cal.getTime().getTime());
cal.set(Calendar.HOUR_OF_DAY, 21);
event.addDate(Event.END, PIMItem.ATTR_NONE, cal.getTime().getTime());
event.addString(BlackBerryEvent.LOCATION, PIMItem.ATTR_NONE, address.getText());
event.addString(Event.NOTE, PIMItem.ATTR_NONE, description.getText());
event.commit();
Dialog.alert(title.getText() + " was added to your calendar.");
} catch (PIMException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
e.printStackTrace();
}
}
祝您好運!
相關問題
- 1. 在MDX中將「YYYYMMDD」格式字符串轉換爲日期?
- 2. 轉換日期時間以字符串格式YYYYMMDD
- 3. 字符串轉換爲日期格式
- 4. 將日期字符串轉換爲SQL可讀日期格式
- 5. 將字符串轉換爲日期並格式化日期
- 6. 如何將字符串轉換爲mysql日期時間格式?
- 7. 如何將日期時間字符串轉換爲sql格式?
- 8. 如何將字符串轉換爲Python中的日期格式?
- 9. 如何將字符串轉換爲日期,又不失格式
- 10. 如何將NSString轉換爲日期格式化的字符串
- 11. Oracle:如何將字符串轉換爲日期格式
- 12. 將日期字符串轉換爲需要的日期字符串格式
- 13. 將YYYYMMDD格式的JavaScript字符串中的日期轉換爲JavaScript日期的最佳方式是什麼?
- 14. android將字符串轉換爲日期格式轉換回字符串
- 15. 使用yyyyMMdd格式化將字符串轉換爲DateTime
- 16. SQL日期格式轉換YYYYMMDD
- 17. Hive如何將日期字符串只轉換爲日期格式?
- 18. 如何在MySQL中將日期字符串轉換爲日期格式
- 19. 如何將JSON字符串日期轉換爲自定義格式日期?
- 20. 如何使用Python將日期字符串轉換爲Solr日期格式?
- 21. 字符串轉換爲日期在.NET如果我傳入的日期格式爲YYYYMMDD
- 22. 轉換YYYYMMDD字符串日期爲datetime值
- 23. 轉換日期格式字符串
- 24. 將字符串轉換爲日期並將日期轉換回字符串
- 25. 將字符串轉換日期到另一個日期格式
- 26. 如何將字符串日期格式轉換
- 27. 字符串日期轉換爲sql日期格式MM/dd/yyyy?
- 28. 轉換PHP日期字符串「月」日期格式爲大寫
- 29. 如何字符串轉換爲日期時間格式的Mysql
- 30. 如何將數字1轉換爲日期值20150101(yyyyMMdd)?
你是怎麼找到String格式的日期的?你從哪裏得到它? –