Here you can find the source of getNodeValueAsTime(Node node)
Parameter | Description |
---|---|
node | Description of the Parameter |
public final static long getNodeValueAsTime(Node node) throws DOMException
//package com.java2s; /**//w w w. j ava 2s. c om * Copyright (c) 1999-2007, Fiorano Software Technologies Pvt. Ltd. and affiliates. * Copyright (c) 2008-2015, Fiorano Software Pte. Ltd. and affiliates. * * All rights reserved. * * This software is the confidential and proprietary information * of Fiorano Software ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * enclosed with this product or entered into with Fiorano. */ import org.w3c.dom.*; public class Main { /** * Gets the node value as time. * *@param node Description of the Parameter *@return The nodeValueAsTime value *@exception DOMException Description of the Exception */ public final static long getNodeValueAsTime(Node node) throws DOMException { if (node == null) return -1; NamedNodeMap attrs = node.getAttributes(); Node attr = attrs.getNamedItem("Unit"); int factor = 1; String unit = attr.getNodeValue(); if (unit.equals("sec")) { factor = 1000; } else if (unit.equals("min")) { factor = 60000; } else if (unit.equals("hr")) { factor = 3600000; } else if (unit.equals("day")) { factor = 86400000; } node = node.getFirstChild(); if (node != null) { String time = node.getNodeValue().trim(); return Integer.parseInt(time) * factor; } return -1; } }