Java Code Examples for org.joda.time.format.PeriodFormat#wordBased()

The following examples show how to use org.joda.time.format.PeriodFormat#wordBased() . 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: ValidationLogicImpl.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private String getFormattedExpirationMinutes() {
	int expirationMinutes = serverConfigurationService.getInt(MAX_PASSWORD_RESET_MINUTES, MAX_PASSWORD_RESET_MINUTES_DEFAULT);
	Period period = new Period(expirationMinutes * 60 * 1000);
	PeriodFormatter periodFormatter = PeriodFormat.wordBased(rl.getLocale());
	return periodFormatter.print(period);
}
 
Example 2
Source File: ValidationLogicImpl.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private String getFormattedExpirationMinutes() {
	int expirationMinutes = serverConfigurationService.getInt(MAX_PASSWORD_RESET_MINUTES, MAX_PASSWORD_RESET_MINUTES_DEFAULT);
	Period period = new Period(expirationMinutes * 60 * 1000);
	PeriodFormatter periodFormatter = PeriodFormat.wordBased(rl.getLocale());
	return periodFormatter.print(period);
}
 
Example 3
Source File: FormProducer.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Converts some number of minutes into a presentable String'
 * ie for English:
 * 122 minutes  ->      2 hours 2 minutes
 * 121 minutes  ->      2 hours 1 minute
 * 120 minutes  ->      2 hours
 * 62 minutes   ->      1 hour 2 minutes
 * 61 minutes   ->      1 hour 1 minute
 * 60 minutes   ->      1 hour
 * 2 minutes    ->      2 minutes
 * 1 minutes    ->      1 minute
 * 0 minutes    ->      0 minutes
 * Works with other languages too.
 * @param totalMinutes some number of minutes
 * @return a presentable String representation of totalMinutes
 */
public String getFormattedMinutes(int totalMinutes)
{
	// Create a joda time period (takes milliseconds)
	Period period = new Period(totalMinutes*60*1000);
	// format the period for the locale
	/* 
	 * Covers English, Danish, Dutch, French, German, Japanese, Portuguese, and Spanish. 
	 * To translate into others, see http://joda-time.sourceforge.net/apidocs/org/joda/time/format/PeriodFormat.html#wordBased(java.util.Locale)
	 * (ie. put the properties mentioned in http://joda-time.sourceforge.net/apidocs/src-html/org/joda/time/format/PeriodFormat.html#line.94 into the classpath resource bundle)
	 */
	PeriodFormatter periodFormatter = PeriodFormat.wordBased(getLocale());
	return periodFormatter.print(period);
}
 
Example 4
Source File: PasswordResetProducer.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Converts some number of minutes into a presentable String'
 * ie for English:
 * 122 minutes	->	2 hours 2 minutes
 * 121 minutes	->	2 hours 1 minute
 * 120 minutes	->	2 hours
 * 62 minutes	->	1 hour 2 minutes
 * 61 minutes	->	1 hour 1 minute
 * 60 minutes	->	1 hour
 * 2 minutes	->	2 minutes
 * 1 minutes	->	1 minute
 * 0 minutes	->	0 minutes
 * Works with other languages too.
 * @param totalMinutes some number of minutes
 * @return a presentable String representation of totalMinutes
 */
public String getFormattedMinutes(int totalMinutes)
{
	// Create a joda time period (takes milliseconds)
	Period period = new Period(totalMinutes*60*1000);
	// format the period for the locale
	/* 
	 * Covers English, Danish, Dutch, French, German, Japanese, Portuguese, and Spanish. 
	 * To translate into others, see http://joda-time.sourceforge.net/apidocs/org/joda/time/format/PeriodFormat.html#wordBased(java.util.Locale)
	 * (ie. put the properties mentioned in http://joda-time.sourceforge.net/apidocs/src-html/org/joda/time/format/PeriodFormat.html#line.94 into the classpath resource bundle)
	 */
	PeriodFormatter periodFormatter = PeriodFormat.wordBased(getLocale());
	return periodFormatter.print(period);
}
 
Example 5
Source File: FormProducer.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Converts some number of minutes into a presentable String'
 * ie for English:
 * 122 minutes  ->      2 hours 2 minutes
 * 121 minutes  ->      2 hours 1 minute
 * 120 minutes  ->      2 hours
 * 62 minutes   ->      1 hour 2 minutes
 * 61 minutes   ->      1 hour 1 minute
 * 60 minutes   ->      1 hour
 * 2 minutes    ->      2 minutes
 * 1 minutes    ->      1 minute
 * 0 minutes    ->      0 minutes
 * Works with other languages too.
 * @param totalMinutes some number of minutes
 * @return a presentable String representation of totalMinutes
 */
public String getFormattedMinutes(int totalMinutes)
{
	// Create a joda time period (takes milliseconds)
	Period period = new Period(totalMinutes*60*1000);
	// format the period for the locale
	/* 
	 * Covers English, Danish, Dutch, French, German, Japanese, Portuguese, and Spanish. 
	 * To translate into others, see http://joda-time.sourceforge.net/apidocs/org/joda/time/format/PeriodFormat.html#wordBased(java.util.Locale)
	 * (ie. put the properties mentioned in http://joda-time.sourceforge.net/apidocs/src-html/org/joda/time/format/PeriodFormat.html#line.94 into the classpath resource bundle)
	 */
	PeriodFormatter periodFormatter = PeriodFormat.wordBased(getLocale());
	return periodFormatter.print(period);
}
 
Example 6
Source File: PasswordResetProducer.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * Converts some number of minutes into a presentable String'
 * ie for English:
 * 122 minutes	->	2 hours 2 minutes
 * 121 minutes	->	2 hours 1 minute
 * 120 minutes	->	2 hours
 * 62 minutes	->	1 hour 2 minutes
 * 61 minutes	->	1 hour 1 minute
 * 60 minutes	->	1 hour
 * 2 minutes	->	2 minutes
 * 1 minutes	->	1 minute
 * 0 minutes	->	0 minutes
 * Works with other languages too.
 * @param totalMinutes some number of minutes
 * @return a presentable String representation of totalMinutes
 */
public String getFormattedMinutes(int totalMinutes)
{
	// Create a joda time period (takes milliseconds)
	Period period = new Period(totalMinutes*60*1000);
	// format the period for the locale
	/* 
	 * Covers English, Danish, Dutch, French, German, Japanese, Portuguese, and Spanish. 
	 * To translate into others, see http://joda-time.sourceforge.net/apidocs/org/joda/time/format/PeriodFormat.html#wordBased(java.util.Locale)
	 * (ie. put the properties mentioned in http://joda-time.sourceforge.net/apidocs/src-html/org/joda/time/format/PeriodFormat.html#line.94 into the classpath resource bundle)
	 */
	PeriodFormatter periodFormatter = PeriodFormat.wordBased(getLocale());
	return periodFormatter.print(period);
}