### Question:
AbstractFlagEncoder implements FlagEncoder, TurnCostEncoder { protected static int parseDuration( String str ) { if (str == null) return 0; try { if (str.startsWith("P")) return 0; int index = str.indexOf(":"); if (index > 0) { String hourStr = str.substring(0, index); String minStr = str.substring(index + 1); index = minStr.indexOf(":"); int minutes = 0; if (index > 0) { String dayStr = hourStr; hourStr = minStr.substring(0, index); minStr = minStr.substring(index + 1); minutes = Integer.parseInt(dayStr) * 60 * 24; } minutes += Integer.parseInt(hourStr) * 60; minutes += Integer.parseInt(minStr); return minutes; } else { return Integer.parseInt(str); } } catch (Exception ex) { logger.warn("Cannot parse " + str + " using 0 minutes"); } return 0; } AbstractFlagEncoder( PMap properties );  AbstractFlagEncoder( String propertiesStr ); protected  AbstractFlagEncoder( int speedBits, double speedFactor, int maxTurnCosts ); void setRegistered( boolean registered ); @Override boolean isRegistered(); void setBlockByDefault( boolean blockByDefault ); void setBlockFords( boolean blockFords ); boolean isBlockFords(); int defineNodeBits( int index, int shift ); int defineWayBits( int index, int shift ); int defineRelationBits( int index, int shift ); abstract long handleRelationTags( OSMRelation relation, long oldRelationFlags ); abstract long acceptWay( OSMWay way ); abstract long handleWayTags( OSMWay way, long allowed, long relationFlags ); long handleNodeTags( OSMNode node ); @Override InstructionAnnotation getAnnotation( long flags, Translation tr ); long reverseFlags( long flags ); long flagsDefault( boolean forward, boolean backward ); @Override long setAccess( long flags, boolean forward, boolean backward ); @Override long setSpeed( long flags, double speed ); @Override double getSpeed( long flags ); @Override long setReverseSpeed( long flags, double speed ); @Override double getReverseSpeed( long flags ); @Override long setProperties( double speed, boolean forward, boolean backward ); @Override double getMaxSpeed(); @Override int hashCode(); @Override boolean equals( Object obj ); void applyWayTags( OSMWay way, EdgeIteratorState edge ); int defineTurnBits( int index, int shift ); @Override boolean isTurnRestricted( long flags ); @Override double getTurnCost( long flags ); @Override long getTurnFlags( boolean restricted, double costs ); @Override boolean isBackward( long flags ); @Override boolean isForward( long flags ); @Override long setBool( long flags, int key, boolean value ); @Override boolean isBool( long flags, int key ); @Override long setLong( long flags, int key, long value ); @Override long getLong( long flags, int key ); @Override long setDouble( long flags, int key, double value ); @Override double getDouble( long flags, int key ); @Override boolean supports( Class<?> feature );  }### Answer:
@Test public void testParseDuration() { assertEquals(10, AbstractFlagEncoder.parseDuration("00:10")); assertEquals(70, AbstractFlagEncoder.parseDuration("01:10")); assertEquals(0, AbstractFlagEncoder.parseDuration("oh")); assertEquals(0, AbstractFlagEncoder.parseDuration(null)); assertEquals(60 * 20, AbstractFlagEncoder.parseDuration("20:00")); assertEquals(60 * 20, AbstractFlagEncoder.parseDuration("0:20:00")); assertEquals(60 * 24 * 2 + 60 * 20 + 2, AbstractFlagEncoder.parseDuration("02:20:02")); }