List of usage examples for org.joda.time LocalDateTime LocalDateTime
public LocalDateTime(Object instant)
From source file:com.sandata.lab.common.utils.date.DateUtil.java
License:Open Source License
public static Date convertUTCToTargetTimeZone(Date date, String timezoneName) { return new LocalDateTime(date.getTime()).toDateTime(DateTimeZone.UTC) .toDateTime(DateTimeZone.forID(timezoneName)).toLocalDateTime().toDate(); }
From source file:com.sandata.lab.common.utils.date.DateUtil.java
License:Open Source License
public static Date convertFromTimeZoneToUTC(Date date, String timezoneName) { return new LocalDateTime(date.getTime()).toDateTime(DateTimeZone.forID(timezoneName)) .toDateTime(DateTimeZone.UTC).toLocalDateTime().toDate(); }
From source file:com.sandata.lab.common.utils.date.DateUtil.java
License:Open Source License
public static Date combineDateAndTime(Date date, LocalTime time) { return new LocalDateTime(date.getTime()).withHourOfDay(time.getHourOfDay()) .withMinuteOfHour(time.getMinuteOfHour()).withSecondOfMinute(time.getSecondOfMinute()) .withMillisOfSecond(time.getMillisOfSecond()).toDate(); }
From source file:com.the.todo.command.ToDoAdd.java
License:MIT License
/** * This method will set the data that is pass in by createToDo method * and set the data into their respective field * /* w w w. ja v a 2s .co m*/ * @param type - type of task that the user wanted. * @param title - the subject that the user wanted. * @param dateGroup - the List of date that the user wanted. * @param category - the group where the user wanted to put the task under. * @param priority - the importance of the task that the user specified. * @return the todo task that is created. */ private ToDo createToDoType(Type type, String title, List<DateGroup> dateGroup, String category, Priority priority) { ToDo todo = null; switch (type) { case FLOATING: todo = new ToDo(title); break; case DEADLINE: LocalDateTime dueDateTime = new LocalDateTime(dateGroup.get(0).getDates().get(0)); todo = new ToDo(title, dueDateTime); break; case TIMED: LocalDateTime startDateTime = new LocalDateTime(dateGroup.get(0).getDates().get(0)); LocalDateTime endDateTime = new LocalDateTime(dateGroup.get(0).getDates().get(1)); todo = new ToDo(title, startDateTime, endDateTime); break; } if (category != null) { todo.setCategory(category); } if (priority != null) { todo.setPriority(priority); } return todo; }
From source file:com.the.todo.command.ToDoEdit.java
License:MIT License
/** * /*from www . j av a2 s. c o m*/ * This method set the data into respective fields according to the keyword entered by the user. * * @param fieldType - type of task * @param remainingString - remaining input by the user after extracting the necessary information * for different fields * @param todo - Task that the user wanted to edit. * @return - edited task. * @throws InvalidDateException - invalid date. */ private ToDo processFieldType(String fieldType, String remainingString, ToDo todo) throws InvalidDateException { fieldType = fieldType.toUpperCase(); FieldType typeOfField = FieldType.valueOf(fieldType); List<DateGroup> groups; LocalDateTime date; switch (typeOfField) { case T: case TITLE: todo.setTitle(remainingString); break; case C: case CATEGORY: if (remainingString.contains("+")) { todo.setCategory(remainingString); } else { todo.setCategory("+" + remainingString); } break; case S: case STARTDATE: groups = DateAndTimeParser.parse(remainingString); date = new LocalDateTime(groups.get(0).getDates().get(0)); todo.setStartDate(date); break; case E: case ENDDATE: groups = DateAndTimeParser.parse(remainingString); date = new LocalDateTime(groups.get(0).getDates().get(0)); todo.setEndDate(date); break; case P: case PRIORITY: Priority priorityChosen = Priority .valueOf(remainingString.toUpperCase().replace(DELIM_PLUS, DELIM_SPACE).trim()); todo.setPriority(priorityChosen); break; case INVALID: break; default: break; } return todo; }
From source file:com.todev.rabbitmqmanagement.ui.connection.list.ConnectionListEntry.java
License:GNU General Public License
@Override public void displayConnectedAt(long connectedAt) { String text = new LocalDateTime(connectedAt).toString("HH:mm:ss YYYY-MM-dd"); connectedAtView.setText(text);/*from w w w.j a v a2 s .c o m*/ }
From source file:com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.java
License:Open Source License
private void setLatestResourceValues(Map<String, Object> rowMap, List<String> tagHeaders, AwsResourceDetailDto resourceDetail) { LocalDateTime usageStartTimeFromCsv = (LocalDateTime) rowMap.get(DetailedCsvHeaders.USAGE_START_DATE); LocalDateTime existingUsageStartTime = null; if (resourceDetail.usageStartTime != null) { existingUsageStartTime = new LocalDateTime(resourceDetail.usageStartTime); }//from w w w .ja va2 s . co m if (existingUsageStartTime == null || existingUsageStartTime.compareTo(usageStartTimeFromCsv) <= 0) { resourceDetail.itemDescription = getStringFieldValue(rowMap, DetailedCsvHeaders.ITEM_DESCRIPTION); resourceDetail.usageStartTime = usageStartTimeFromCsv.toDate().getTime(); resourceDetail.tags = getTagsForResources(rowMap, tagHeaders); boolean isRowMarkedAsReserved = convertReservedInstance( getStringFieldValue(rowMap, DetailedCsvHeaders.IS_RESERVED_INSTANCE)); boolean isResourceReservedForThisHour; Long millisForBillDay = getMillisForHour(usageStartTimeFromCsv); if (existingUsageStartTime != null && existingUsageStartTime.isEqual(usageStartTimeFromCsv)) { isResourceReservedForThisHour = resourceDetail.isReservedInstance || isRowMarkedAsReserved; if (isRowMarkedAsReserved && !resourceDetail.isReservedInstance) { resourceDetail.addToHoursAsReservedPerDay(millisForBillDay, 1.0); } } else { isResourceReservedForThisHour = isRowMarkedAsReserved; if (isResourceReservedForThisHour) { resourceDetail.addToHoursAsReservedPerDay(millisForBillDay, 1.0); } } resourceDetail.isReservedInstance = isResourceReservedForThisHour; } }
From source file:com.wavemaker.commons.data.mapper.WMDateColumnLocalDateTimeMapper.java
License:Apache License
@Override public LocalDateTime fromNonNullString(String s) { return new LocalDateTime(s); }
From source file:control.ConfigController.java
public static String getLastBackupDate() { dao = new GenericDAO(); String s = dao.get("app_config", "last_backup"); LocalDateTime ldt = new LocalDateTime(s); s = "" + ldt.toDate().toLocaleString() + ""; return s;// w w w. j a va 2 s .co m }
From source file:control.ConfigController.java
public static boolean doDailyBackup() { cdao = new ConfigDAO(); if (cdao.isSetAutoBackup()) { dao = new GenericDAO(); String s = dao.get("app_config", "last_backup"); LocalDateTime hoje = new LocalDateTime(System.currentTimeMillis()); LocalDateTime last_bkp = new LocalDateTime(s); Period p = new Period(hoje, last_bkp); if ((p.getDays() < 0) || (s == null)) { java.io.File file = new java.io.File( System.getProperty("user.home") + System.getProperty("file.separator") + ".jbiblioteca" + System.getProperty("file.separator") + "jbiblioteca_bkp.db"); try { Database.backupDatabase(file); ConfigController.saveLastBackupDate("'" + hoje.toString() + "'"); System.out.println("Backup \"" + file.getCanonicalPath() + "\" salvo. "); } catch (Exception ex) { Logger.getLogger(ConfigController.class.getName()).log(Level.SEVERE, null, ex); }//www . j a va 2 s .c om return true; } } return false; }