Exemple #1
0
        public void TestConvertTime()
        {
            double delta = 1E-7; // a couple of digits more accuracy than strictly required

            Assert.AreEqual(0.5, DateUtil.ConvertTime("12:00"), delta);
            Assert.AreEqual(2.0 / 3, DateUtil.ConvertTime("16:00"), delta);
            Assert.AreEqual(0.0000116, DateUtil.ConvertTime("0:00:01"), delta);
            Assert.AreEqual(0.7330440, DateUtil.ConvertTime("17:35:35"), delta);
        }
        public void TestApplyCellForTimeFormat()
        {
            // Create a workbook, IRow and ICell to test with
            IWorkbook wb    = new HSSFWorkbook();
            ISheet    sheet = wb.CreateSheet();
            IRow      row   = sheet.CreateRow(0);
            ICell     cell  = row.CreateCell(0);

            CellFormat cf = CellFormat.GetInstance("hh:mm");

            cell.SetCellValue(DateUtil.ConvertTime("03:04:05"));
            CellFormatResult result = cf.Apply(cell);

            Assert.AreEqual("03:04", result.Text);
        }