Ruby 基础学习 2

异常处理的写法

1
2
3
4
5
6
7
begin
可能会发生异常的处理
rescue => ex
print ex.message, "\n" 发生异常的处理
ensure
不管是否发生异常都希望执行的处理
end

閱讀更多

Ruby 基础学习 1

Ruby基础教程第九章

閱讀更多

Ruby on Rails 环境搭建

开发环境

    閱讀更多

    周日游

    好吧,逛了一天回来坐在电脑前,打开心爱的Atom,记录下这在成长路上迈出得一小步。

    閱讀更多

    Java Date Format

    Use SimpleDateFormat#parse() to parse a String in a certain pattern into a Date.

    1
    2
    String oldstring = "2011-01-18 00:00:00.0";
    Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").parse(oldstring);

    Use SimpleDateFormat#format() to format a Date into a String in a certain pattern.

    1
    2
    String newstring = new SimpleDateFormat("yyyy-MM-dd").format(date);
    System.out.Jprintln(newstring); // 2011-01-18

    Update: as per your failed attempt: the patterns are case sensitive. Read the SimpleDateFormatjavadoc what the individual parts stands for. So stands for example M for months and m for minutes. Also, years exist of four digits, not five. Look closer at the code snippets I posted here above.

    閱讀更多