List of usage examples for org.joda.time.format DateTimeFormat forPattern
public static DateTimeFormatter forPattern(String pattern)
From source file:ch.icclab.cyclops.model.ceilometerMeasurements.AbstractOpenStackCeilometerUsage.java
License:Open Source License
/** * Will compute number of milliseconds from epoch to startDate * * @param time as string/*from ww w . j av a 2 s.c o m*/ * @return milliseconds since epoch */ public static long getMilisForTime(String time) { // first we have to get rid of 'T', as we need just T String isoFormat = time.replace("'", ""); // then we have to create proper formatter DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS") .withLocale(Locale.ROOT).withChronology(ISOChronology.getInstanceUTC()); // and now parse it DateTime dt = formatter.parseDateTime(isoFormat); return dt.getMillis(); }
From source file:ch.icclab.cyclops.model.UsageData.java
License:Open Source License
/** * Will compute number of milliseconds from epoch to startDate * * @param time as string//from w w w .ja v a2 s . c o m * @return milliseconds since epoch */ public static long getMilisForTime(String time) { // first we have to get rid of 'T', as we need just T String isoFormat = time.replace("'", ""); // then we have to create proper formatter DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); // and now parse it DateTime dt = formatter.parseDateTime(isoFormat); return dt.getMillis(); }
From source file:ch.icclab.cyclops.persistence.orm.InstanceORM.java
License:Open Source License
/** * Current time/*from w w w . java 2 s. c o m*/ * @return string */ private String getCurrentTime() { DateTimeFormatter fmt = DateTimeFormat.forPattern("H:m:s.S d/MMM/y"); return fmt.print(new DateTime()); }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.util.Time.java
License:Open Source License
/** * This method computes the date of String time (with support for 'T' and time zones) * * @param full//from w ww . j a v a 2 s . c om * @return UTC DateTime object */ public static DateTime getDateForTime(String full) { String day = (full.contains("T")) ? full.substring(0, full.indexOf("T")) : full; // convert it to time object DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); return formatter.parseDateTime(day); }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.util.Time.java
License:Open Source License
/** * Normalise date in string format/*from ww w. j av a 2 s .co m*/ * * @param original string * @return normalised string */ public static String normaliseString(String original) { try { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); // and now parse it DateTime dt = formatter.parseDateTime(original); return dt.toString(); } catch (Exception ignored) { return original; } }
From source file:ch.icclab.cyclops.usecases.tnova.model.RevenueSharingEntry.java
License:Open Source License
/** * Will compute number of milliseconds from epoch to startDate * * @param time as string//ww w .jav a 2 s . co m * @return milliseconds since epoch */ public static long getMillisForTime(String time) { // first we have to get rid of 'T', as we need just T String isoFormat = time.replace("'", ""); // then we have to create proper formatter DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); // and now parse it DateTime dt = formatter.parseDateTime(isoFormat); return dt.getMillis(); }
From source file:ch.icclab.cyclops.util.Time.java
License:Open Source License
/** * Will compute number of milliseconds from epoch to startDate * * @param time as string//from w w w . j a v a2 s. c om * @return milliseconds since epoch */ public static long getMilisForTime(String time) { // first we have to get rid of 'T', as we need just T String isoFormat = time.replace("'", ""); // then we have to create proper formatter DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); // and now parse it DateTime dt = formatter.parseDateTime(isoFormat); return dt.getMillis(); }
From source file:ch.icclab.cyclops.util.Time.java
License:Open Source License
/** * This method computes the date of String time (with support for 'T' and time zones) * * @param full// www . ja va 2 s. c om * @return UTC DateTime object */ public static DateTime getDateForTime(String full) { // convert it to time object DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); return formatter.parseDateTime(full); }
From source file:ch.icclab.cyclops.util.Time.java
License:Open Source License
public static Long fromNovaTimeToMills(String time) { DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS").withZoneUTC(); DateTime date = format.parseDateTime(time); return date.getMillis(); }
From source file:ch.icclab.cyclops.util.Time.java
License:Open Source License
public static Long fromOpenstackTimeToMills(String time) { DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd' 'HH:mm:ss.SSSSSS").withZoneUTC(); DateTime date = format.parseDateTime(time); return date.getMillis(); }