時間格式的設定

2021-04-12 17:55:46 字數 2065 閱讀 3362

在進行formview顯示時間資料的時候,發現格式仍然是日期和時間的完整格式,如是進行了dataformatstring="的設定.如下所示:

<

asp:boundfield headertext="

displaytext

"datafield="

fieldname

"dataformatstring="

">

<

itemstyle horizontalalign="

right

"width="

60px

">

itemstyle

>

<

headerstyle horizontalalign="

right

">

headerstyle

>

asp:boundfield

>

<

asp:boundfield headertext="

displaytext

"datafield="

fieldname

"dataformatstring="

"htmlencode=

"false

">

<

itemstyle horizontalalign="

right

"width="

60px

">

itemstyle

>

<

headerstyle horizontalalign="

right

">

headerstyle

>

asp:boundfield

>

編譯,正常顯示.

附:asp.net資料格式的format-- dataformatstring

欄位的dataformatstring 屬性使用語法如下:

dataformatstring=""

在dataformatstring 中的 表示資料本身,而在冒號後面的格式字串代表所們希望資料顯示的格式;另外在指定的格式符號後可以指定小數所要顯示的位數。例如原來的資料為「12.34」,若格式設定為 ,則輸出為「12.3」。其常用的數值格式如下表所示:

格式字串 資料 結果

"" 12345.6789 $12,345.68

"" -12345.6789 ($12,345.68)

"" 12345 12345

"" 12345 00012345

"" 12345.6789 1234568e+004

"" 12345.6789 1.2345678900e+004

"" 12345.6789 12345.68

"" 12345.6789 12346

"" 12345.6789 12345.6789

"" 123456789 1.234568e8

"" 12345.6789 12,345.68

"" 123456789 123,456,789.0000

"total: " 12345.6789 total: $12345.68

其常用的日期格式如下表所示:

格式 說明 輸出格式

d 精簡日期格式 mm/dd/yyyy

d 詳細日期格式 dddd, mmmm dd, yyyy

f 完整格式 (long date + short time) dddd, mmmm dd, yyyy hh:mm

f完整日期時間格式

(long date + long time)

dddd, mmmm dd, yyyy hh:mm:ss

g 一般格式 (short date + short time) mm/dd/yyyy hh:mm

g 一般格式 (short date + long time) mm/dd/yyyy hh:mm:ss

m,m 月日格式 mmmm dd

s 適中日期時間格式 yyyy-mm-dd hh:mm:ss

t 精簡時間格式 hh:mm

t 詳細時間格式 hh:mm:ss

設定時間格式的JSpinner

上圖 封裝成函式 public class getspinner catch parseexception e1 spinner.setmodel datemodel 對spinner的時間格式進行設定 spinner.seteditor new jspinner.dateeditor spinne...

設定本地時間格式

在delphi中,特別是在寫管理系統軟體時,經常要用到 formatdatetime 以將 tdatetime 格式的日期時間轉換成字串形式的值顯示或儲存起來,或者用 strtodatetime將字串形式的日期時間轉換成 tdatetime 然後再做其他操作。在進行時間或日期的轉換時,會使用系統當前...

quartz 設定時間格式

乙個cron表示式有至少6個 也可能7個 有空格分隔的時間元素。按順序依次為 1.秒 0 59 2.分鐘 0 59 3.小時 0 23 4.天 月 0 31,但是你需要考慮你月的天數 5.月 0 11 6.天 星期 1 7 1 sun 或 sun,mon,tue,wed,thu,fri,sat 7....