Java Code Examples for net.sf.mpxj.TimeUnit#getInstance()

The following examples show how to use net.sf.mpxj.TimeUnit#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Record.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Accessor method used to retrieve an Integer object representing the
 * contents of an individual field. If the field does not exist in the
 * record, null is returned.
 *
 * @param field the index number of the field to be retrieved
 * @return the value of the required field
 */
public TimeUnit getTimeUnit(int field)
{
   TimeUnit result;

   if ((field < m_fields.length) && (m_fields[field].length() != 0))
   {
      result = TimeUnit.getInstance(Integer.parseInt(m_fields[field]));
   }
   else
   {
      result = TimeUnit.DAYS;
   }

   return (result);
}
 
Example 2
Source File: TimeUnitUtility.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method is used to parse a string representation of a time
 * unit, and return the appropriate constant value.
 *
 * @param units string representation of a time unit
 * @param locale target locale
 * @return numeric constant
 * @throws MPXJException normally thrown when parsing fails
 */
@SuppressWarnings("unchecked") public static TimeUnit getInstance(String units, Locale locale) throws MPXJException
{
   Map<String, Integer> map = LocaleData.getMap(locale, LocaleData.TIME_UNITS_MAP);
   Integer result = map.get(units.toLowerCase());
   if (result == null)
   {
      throw new MPXJException(MPXJException.INVALID_TIME_UNIT + " " + units);
   }
   return (TimeUnit.getInstance(result.intValue()));
}
 
Example 3
Source File: DatatypeConverter.java    From mpxj with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Parse time unit.
 *
 * @param value time unit value
 * @return TimeUnit instance
 */
public static final TimeUnit parseTimeUnit(Number value)
{
   return (TimeUnit.getInstance(NumberHelper.getInt(value) - 1));
}
 
Example 4
Source File: MPPUtility.java    From mpxj with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * This method maps from the value used to specify default work units in the
 * MPP file to a standard TimeUnit.
 *
 * @param value Default work units
 * @return TimeUnit value
 */
public static TimeUnit getWorkTimeUnits(int value)
{
   return TimeUnit.getInstance(value - 1);
}